about summary refs log tree commit diff
path: root/pkgs/applications/networking/kubo
diff options
context:
space:
mode:
authorLuflosi <luflosi@luflosi.de>2023-10-08 18:56:05 +0200
committerLuflosi <luflosi@luflosi.de>2023-10-10 10:46:25 +0200
commitcf8aa48605d68997be93f69ce853d76449ff68cc (patch)
tree1e57cd8b2f6d02eab79387abe0693caa1afdf954 /pkgs/applications/networking/kubo
parentb8eebcad828c07879009bce5e3faa4906bb2fabd (diff)
nixos/tests/kubo: various improvements
Add new test to check if kubo.passthru.repoVersion is set correctly.
Also split the existing NixOS VM test into two independent parts. The test already used two independent VMs but just one testScript. This made experimenting with just one of the two VMs slower than it needed to be. It should also increase parallelism slightly since both test scripts can now run at the same time.
Diffstat (limited to 'pkgs/applications/networking/kubo')
-rw-r--r--pkgs/applications/networking/kubo/default.nix6
-rw-r--r--pkgs/applications/networking/kubo/test-repoVersion.nix13
2 files changed, 18 insertions, 1 deletions
diff --git a/pkgs/applications/networking/kubo/default.nix b/pkgs/applications/networking/kubo/default.nix
index defb898b44720..8ffeb2e9fcc19 100644
--- a/pkgs/applications/networking/kubo/default.nix
+++ b/pkgs/applications/networking/kubo/default.nix
@@ -2,6 +2,7 @@
 , buildGoModule
 , fetchurl
 , nixosTests
+, callPackage
 }:
 
 buildGoModule rec {
@@ -29,7 +30,10 @@ buildGoModule rec {
 
   subPackages = [ "cmd/ipfs" ];
 
-  passthru.tests.kubo = nixosTests.kubo;
+  passthru.tests = {
+    inherit (nixosTests) kubo;
+    repoVersion = callPackage ./test-repoVersion.nix {};
+  };
 
   vendorHash = null;
 
diff --git a/pkgs/applications/networking/kubo/test-repoVersion.nix b/pkgs/applications/networking/kubo/test-repoVersion.nix
new file mode 100644
index 0000000000000..25fd8fcfbf43a
--- /dev/null
+++ b/pkgs/applications/networking/kubo/test-repoVersion.nix
@@ -0,0 +1,13 @@
+{ runCommand, kubo }:
+
+runCommand "kubo-test-repoVersion" { } ''
+  export IPFS_PATH="$TMPDIR"
+  "${kubo}/bin/ipfs" init --empty-repo
+  declared_repo_version='${kubo.repoVersion}'
+  actual_repo_version="$(cat "$IPFS_PATH/version")"
+  if [ "$declared_repo_version" != "$actual_repo_version" ]; then
+    echo "kubo.repoVersion is not set correctly. It should be $actual_repo_version but is $declared_repo_version."
+    exit 1
+  fi
+  touch "$out"
+''