Skip to content

Commit

Permalink
Add flake.nix and update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaschan committed Aug 11, 2024
1 parent 8a04318 commit d6a5219
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 5 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
coverage
.direnv
61 changes: 61 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
description = "A flake for bash, coreutils, xxd, restic, util-linux, and openssh";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = {
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system: let
pkgs = nixpkgs.legacyPackages.${system};
in {
devShell = pkgs.mkShell {
buildInputs = with pkgs; [
bash
coreutils
kcov
vim # provides xxd
python3
python312Packages.fusepy
restic
screen
shellcheck
tmux
utillinux
openssh
];
};
}
);
}
11 changes: 6 additions & 5 deletions test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,6 @@ test-file-changed-as-read-warning () {
assert-equals-directory "$WORLD_DIR/file3.txt" "$TEST_TMP/restored/$WORLD_DIR/file3.txt"
}



test-lock-defaults () {
TIMESTAMP="$(date +%F_%H-%M-%S --date="2021-01-01")"
./backup.sh -t "$TEST_TMP/lockfile" -i "$TEST_TMP/server/world" -o "$TEST_TMP/backups" -s "$SCREEN_TMP" -f "$TIMESTAMP"
Expand Down Expand Up @@ -241,7 +239,6 @@ test-restic-defaults () {
check-latest-backup-restic
}


test-backup-spaces-in-directory () {
TIMESTAMP="$(date +%F_%H-%M-%S --date="2021-01-01")"
WORLD_SPACES="$TEST_TMP/minecraft server/the world"
Expand Down Expand Up @@ -473,6 +470,7 @@ test-restic-thinning-delete () {
done
EXPECTED_TIMESTAMPS=(
# Weekly
"2021-01-01 00:00:00"

# Daily (30)
"2021-01-01 23:00:00"
Expand Down Expand Up @@ -512,11 +510,14 @@ test-restic-thinning-delete () {
assertContains "$SNAPSHOTS" "$TIMESTAMP"
done
UNEXPECTED_TIMESTAMPS=(
"2021-01-01 00:00:00"
"2021-01-01 01:00:00"
"2021-01-01 02:00:00"
"2021-01-02 22:00:00"
"2021-01-03 22:00:00"
"2021-01-04 00:00:00"
)
for TIMESTAMP in "${UNEXPECTED_TIMESTAMPS[@]}"; do
assertNotContains "$SNAPSHOTS" "$TIMESTAMP"
assertNotContains "$SNAPSHOTS" "$TIMESTAMP"
done
}

Expand Down

0 comments on commit d6a5219

Please sign in to comment.