-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fetchGit: add simple test for ssh fetching
Also move tests to separate files which are auto-imported. This should allow people adding tests concurrently without introducing merge conflicts
- Loading branch information
Showing
5 changed files
with
138 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
description = "can fetch a git repo via http"; | ||
script = '' | ||
# add a file to the repo | ||
client.succeed(f""" | ||
echo chiang-mai > {repo.path}/thailand \ | ||
&& {repo.git} add thailand \ | ||
&& {repo.git} commit -m 'commit1' | ||
""") | ||
# memoize the revision | ||
rev1 = client.succeed(f""" | ||
{repo.git} rev-parse HEAD | ||
""").strip() | ||
# push to the server | ||
client.succeed(f""" | ||
{repo.git} push origin main | ||
""") | ||
# fetch the repo via nix | ||
fetched1 = client.succeed(f""" | ||
nix eval --impure --raw --expr "(builtins.fetchGit {repo.remote}).outPath" | ||
""") | ||
# check if the committed file is there | ||
client.succeed(f""" | ||
test -f {fetched1}/thailand | ||
""") | ||
# check if the revision is the same | ||
rev1_fetched = client.succeed(f""" | ||
nix eval --impure --raw --expr "(builtins.fetchGit {repo.remote}).rev" | ||
""").strip() | ||
assert rev1 == rev1_fetched | ||
''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
description = "can fetch a git repo via ssh"; | ||
script = '' | ||
# add a file to the repo | ||
client.succeed(f""" | ||
echo chiang-mai > {repo.path}/thailand \ | ||
&& {repo.git} add thailand \ | ||
&& {repo.git} commit -m 'commit1' | ||
""") | ||
# memoize the revision | ||
rev1 = client.succeed(f""" | ||
{repo.git} rev-parse HEAD | ||
""").strip() | ||
# push to the server | ||
client.succeed(f""" | ||
{repo.git} push origin-ssh main | ||
""") | ||
# fetch the repo via nix | ||
fetched1 = client.succeed(f""" | ||
nix eval --impure --raw --expr ' | ||
(builtins.fetchGit "{repo.remote_ssh}").outPath | ||
' | ||
""") | ||
# check if the committed file is there | ||
client.succeed(f""" | ||
test -f {fetched1}/thailand | ||
""") | ||
# check if the revision is the same | ||
rev1_fetched = client.succeed(f""" | ||
nix eval --impure --raw --expr ' | ||
(builtins.fetchGit "{repo.remote_ssh}").rev | ||
' | ||
""").strip() | ||
assert rev1 == rev1_fetched | ||
''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters