From 5fe1ec8a05f0074329dfe8ba13b55d583504e4ef Mon Sep 17 00:00:00 2001
From: Eelco Dolstra <edolstra@gmail.com>
Date: Tue, 18 Jan 2022 17:30:50 +0100
Subject: [PATCH] Add a test for 'nix store copy-log' and 'nix log'

---
 tests/binary-cache.sh | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/tests/binary-cache.sh b/tests/binary-cache.sh
index d7bc1507b..2368884f7 100644
--- a/tests/binary-cache.sh
+++ b/tests/binary-cache.sh
@@ -14,6 +14,17 @@ outPath=$(nix-build dependencies.nix --no-out-link)
 
 nix copy --to file://$cacheDir $outPath
 
+# Test copying build logs to the binary cache.
+nix log --store file://$cacheDir $outPath 2>&1 | grep 'is not available'
+nix store copy-log --to file://$cacheDir $outPath
+nix log --store file://$cacheDir $outPath | grep FOO
+rm -rf $TEST_ROOT/var/log/nix
+nix log $outPath 2>&1 | grep 'is not available'
+nix log --substituters file://$cacheDir $outPath | grep FOO
+
+# Test copying build logs from the binary cache.
+nix store copy-log --from file://$cacheDir $(nix-store -qd $outPath)
+nix log $outPath | grep FOO
 
 basicDownloadTests() {
     # No uploading tests bcause upload with force HTTP doesn't work.