summary refs log tree commit diff
diff options
context:
space:
mode:
authorRobert Obryk <robryk@gmail.com>2022-11-28 14:52:29 +0100
committerRobert Obryk <robryk@gmail.com>2022-11-28 14:55:32 +0100
commitccfc1d24214c436b192eebac15d2d8b9129b192f (patch)
treebc24f80fc24f8476a2f22d237db929adb2da2cf6
parent7cdb313558d926bf33927aaddf6d0a9651867604 (diff)
downloadnixpkgs-ccfc1d24214c436b192eebac15d2d8b9129b192f.tar
nixpkgs-ccfc1d24214c436b192eebac15d2d8b9129b192f.tar.gz
nixpkgs-ccfc1d24214c436b192eebac15d2d8b9129b192f.tar.bz2
nixpkgs-ccfc1d24214c436b192eebac15d2d8b9129b192f.tar.lz
nixpkgs-ccfc1d24214c436b192eebac15d2d8b9129b192f.tar.xz
nixpkgs-ccfc1d24214c436b192eebac15d2d8b9129b192f.tar.zst
nixpkgs-ccfc1d24214c436b192eebac15d2d8b9129b192f.zip
nixos/tests/restic: use machine-readable output
This change causes us to stop relying on the way `restic snapshots`
formats its human-readable output.
-rw-r--r--nixos/tests/restic.nix13
1 files changed, 7 insertions, 6 deletions
diff --git a/nixos/tests/restic.nix b/nixos/tests/restic.nix
index 68b5ef20d57..3681c4cf190 100644
--- a/nixos/tests/restic.nix
+++ b/nixos/tests/restic.nix
@@ -102,15 +102,15 @@ import ./make-test-python.nix (
           "timedatectl set-time '2016-12-13 13:45'",
           "systemctl start restic-backups-remotebackup.service",
           "rm /opt/backupCleanupCommand",
-          '${pkgs.restic}/bin/restic -r ${remoteRepository} -p ${passwordFile} snapshots -c | grep -e "^1 snapshot"',
+          '${pkgs.restic}/bin/restic -r ${remoteRepository} -p ${passwordFile} snapshots --json | ${pkgs.jq}/bin/jq "length | . == 1"',
 
           # test that remote-from-file-backup produces a snapshot
           "systemctl start restic-backups-remote-from-file-backup.service",
-          '${pkgs.restic}/bin/restic -r ${remoteFromFileRepository} -p ${passwordFile} snapshots -c | grep -e "^1 snapshot"',
+          '${pkgs.restic}/bin/restic -r ${remoteFromFileRepository} -p ${passwordFile} snapshots --json | ${pkgs.jq}/bin/jq "length | . == 1"',
 
           # test that rclonebackup produces a snapshot
           "systemctl start restic-backups-rclonebackup.service",
-          '${pkgs.restic}/bin/restic -r ${rcloneRepository} -p ${passwordFile} snapshots -c | grep -e "^1 snapshot"',
+          '${pkgs.restic}/bin/restic -r ${rcloneRepository} -p ${passwordFile} snapshots --json | ${pkgs.jq}/bin/jq "length | . == 1"',
 
           # test that custompackage runs both `restic backup` and `restic check` with reasonable commandlines
           "systemctl start restic-backups-custompackage.service",
@@ -143,12 +143,13 @@ import ./make-test-python.nix (
           "rm /opt/backupCleanupCommand",
           "systemctl start restic-backups-rclonebackup.service",
 
-          '${pkgs.restic}/bin/restic -r ${remoteRepository} -p ${passwordFile} snapshots -c | grep -e "^4 snapshot"',
-          '${pkgs.restic}/bin/restic -r ${rcloneRepository} -p ${passwordFile} snapshots -c | grep -e "^4 snapshot"',
+          '${pkgs.restic}/bin/restic -r ${remoteRepository} -p ${passwordFile} snapshots --json | ${pkgs.jq}/bin/jq "length | . == 4"',
+          '${pkgs.restic}/bin/restic -r ${rcloneRepository} -p ${passwordFile} snapshots --json | ${pkgs.jq}/bin/jq "length | . == 4"',
 
           # test that remoteprune brings us back to 1 snapshot in remotebackup
           "systemctl start restic-backups-remoteprune.service",
-          '${pkgs.restic}/bin/restic -r ${remoteRepository} -p ${passwordFile} snapshots -c | grep -e "^1 snapshot"',
+          '${pkgs.restic}/bin/restic -r ${remoteRepository} -p ${passwordFile} snapshots --json | ${pkgs.jq}/bin/jq "length | . == 1"',
+
       )
     '';
   }