aboutsummaryrefslogtreecommitdiffstats
path: root/tests/scenarios.nix
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-12 02:35:25 +0000
committertv <tv@krebsco.de>2026-11-12 02:35:25 +0000
commitb0469337bd8eb3d8e325e82640ac855731975000 (patch)
treea60dcb1210f5417773fed7cffa0666b8977907d0 /tests/scenarios.nix
parentaf300230cf4a70a5681aadf7a8ed35add1b58962 (diff)
tests: deploy an older commit first in the git scenarios
The git scenarios deployed only the commit a clone checks out anyway, so populate never fetched, reset, or updated submodules in a full clone, and fetchAlways made no observable difference. They deploy HEAD's parent first now.
Diffstat (limited to 'tests/scenarios.nix')
-rw-r--r--tests/scenarios.nix22
1 files changed, 17 insertions, 5 deletions
diff --git a/tests/scenarios.nix b/tests/scenarios.nix
index e56cb13..4838b74 100644
--- a/tests/scenarios.nix
+++ b/tests/scenarios.nix
@@ -23,8 +23,9 @@
remoteHost,
# Absolute path of age on the deploying machine.
agePath,
- # HEAD of /fixtures/gitsrc.
+ # HEAD of /fixtures/gitsrc, and its parent.
gitHead,
+ gitFirst,
}:
let
@@ -363,10 +364,10 @@ assert !(krops.isLocalTarget (targets.remote "/"));
gc
expect_eq msg "$(nix_eval "$T"/.populate/flakes/x#msg)" git:alt
'';
- sources = {
+ sources = ref: {
x.git = {
url = gitUrl;
- ref = gitHead;
+ inherit ref;
inherit (flags) shallow fetchAlways;
clean.exclude = optional flags.cleanExclude "keepme";
inputs = optionalAttrs flags.inputs { dep.follows = "alt"; };
@@ -374,15 +375,26 @@ assert !(krops.isLocalTarget (targets.remote "/"));
} // optionalAttrs flags.inputs alt;
in {
phases = [
+ # The older commit first, so deploying HEAD changes the work tree, and
+ # fetches if fetchAlways is set or the clone is shallow.
{
- inherit sources check;
+ sources = sources gitFirst;
+ check = ''
+ expect_eq HEAD "$(git -C "$T"/x rev-parse HEAD)" ${gitFirst}
+ expect_eq commits "$(git -C "$T"/x rev-list --count HEAD)" 1
+ test ! -e "$T"/x/two || fail "two present"
+ '';
+ }
+ {
+ sources = sources gitHead;
+ inherit check;
mutate = ''
echo junk > "$T"/x/junk
echo keepme > "$T"/x/keepme
'';
}
{
- inherit sources;
+ sources = sources gitHead;
check = check + ''
test ! -e "$T"/x/junk || fail "junk not cleaned"
${if flags.cleanExclude then ''