Skip to content

Commit

Permalink
test(itest): add simple integration tests for most forges
Browse files Browse the repository at this point in the history
This commit adds simple integration tests for most forges. Notice that there
isn't a self hosted gitlab (yet), because I haven't found one yet. When I do
that, I'll make sure to add it.
  • Loading branch information
cafkafk committed Oct 30, 2023
1 parent 3dd2c37 commit f94d4d5
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,31 @@ alias c := cross
# Generate Checksums
# TODO: moved to gh-release just checksum

testString := "The fault, dear Brutus, is not in our flakes, but in our governance, that we aren't moderators."

run_test TARGET:
#!/usr/bin/env bash
set -euxo pipefail
test_dir=`mktemp -d -t "XXXXXXX-rime-itest"`
nix run {{TARGET}} --refresh 2> $test_dir/nix-run.log 1> $test_dir/nix-run.out
diff -U3 --color=auto <(cat $test_dir/nix-run.out) <(echo "{{testString}}")
if grep -q 'warning: error:' $test_dir/nix-run.log; then
cat $test_dir/nix-run.log;
rm $test_dir -r
echo "tests failed >_<"
exit 1
fi
rm $test_dir -r


# Integration Testing (requires Nix)
itest:
set -euxo pipefail
just run_test "http://localhost:3000/v1/codeberg/cafkafk/hello.tar.gz"
just run_test "http://localhost:3000/v1/github/cafkafk/hello.tar.gz"
just run_test "http://localhost:3000/v1/gitlab/gitlab.com/cafkafk/hello.tar.gz"
just run_test "http://localhost:3000/v1/gitlab/gitlab.com/cafkafk/hello.tar.gz"
just run_test "http://localhost:3000/v1/forgejo/next.forgejo.org/cafkafk/hello.tar.gz"
just run_test "http://localhost:3000/v1/flakehub/cafkafk/hello/v/v0.0.1.tar.gz"
# TODO: self hosted gitlab
@echo "tests passsed :3"

0 comments on commit f94d4d5

Please sign in to comment.