about summary refs log tree commit diff
path: root/pkgs/tools/misc/fend
diff options
context:
space:
mode:
authorOlli Helenius <liff@iki.fi>2023-10-29 09:58:16 +0200
committerOlli Helenius <liff@iki.fi>2023-10-30 22:39:35 +0200
commit1617eeca678b9b1a2e52e3474ee4b624b5efa12f (patch)
tree95881e19be6f9a8c02c6e433709e9f7c3fb6abd8 /pkgs/tools/misc/fend
parent749d5f3b0f59b016be17da3009276d5f2f886931 (diff)
fend: add package tests
Diffstat (limited to 'pkgs/tools/misc/fend')
-rw-r--r--pkgs/tools/misc/fend/default.nix20
1 files changed, 19 insertions, 1 deletions
diff --git a/pkgs/tools/misc/fend/default.nix b/pkgs/tools/misc/fend/default.nix
index f84322ad70763..12e88857b8711 100644
--- a/pkgs/tools/misc/fend/default.nix
+++ b/pkgs/tools/misc/fend/default.nix
@@ -8,6 +8,10 @@
 , copyDesktopItems
 , makeDesktopItem
 , nix-update-script
+, testers
+, writeText
+, runCommand
+, fend
 }:
 
 rustPlatform.buildRustPackage rec {
@@ -58,7 +62,21 @@ rustPlatform.buildRustPackage rec {
     })
   ];
 
-  passthru.updateScript = nix-update-script { };
+  passthru = {
+    updateScript = nix-update-script { };
+    tests = {
+      version = testers.testVersion { package = fend; };
+      units = testers.testEqualContents {
+        assertion = "fend does simple math and unit conversions";
+        expected = writeText "expected" ''
+          36 kph
+        '';
+        actual = runCommand "actual" { } ''
+          ${lib.getExe fend} '(100 meters) / (10 seconds) to kph' > $out
+        '';
+      };
+    };
+  };
 
   meta = with lib; {
     description = "Arbitrary-precision unit-aware calculator";