Add test target to Makefile to run full integration tests
This commit is contained in:
parent
ddb126db17
commit
a759fc28f7
35
Makefile
35
Makefile
@ -1,34 +1,23 @@
|
|||||||
SKIP_SERVICES = []
|
|
||||||
|
|
||||||
all:
|
CONFIG = ./config.nix
|
||||||
|
|
||||||
|
entrypoint:
|
||||||
nix-build -A entrypoint \
|
nix-build -A entrypoint \
|
||||||
--arg baseConfig '(import ./config.nix)' \
|
--arg baseConfig '(import ${CONFIG})'
|
||||||
--arg baseSkipServices '${SKIP_SERVICES}'
|
|
||||||
|
|
||||||
run: all
|
install:
|
||||||
|
nix-build -A install --arg baseConfig '(import ${CONFIG})'
|
||||||
./result
|
./result
|
||||||
|
|
||||||
all.prod:
|
test:
|
||||||
nix-build -A entrypoint \
|
$$(nix-build --no-out-link -A pkgs.bash)/bin/bash test.sh
|
||||||
--arg baseConfig '(import ./prod.config.nix)' \
|
@if [ $$? == 0 ]; then echo "TESTS PASSED!"; else echo "TESTS FAILED!"; fi
|
||||||
--arg baseSkipServices '${SKIP_SERVICES}'
|
|
||||||
|
|
||||||
run.prod: all.prod
|
|
||||||
./result
|
|
||||||
|
|
||||||
install.prod:
|
|
||||||
nix-build -A install --arg baseConfig '(import ./prod.config.nix)'
|
|
||||||
./result
|
|
||||||
|
|
||||||
srv.shell:
|
srv.shell:
|
||||||
nix-shell -A srv.shell --command 'cd srv; return'
|
nix-shell -A srv.shell --arg baseConfig '(import ${CONFIG})' \
|
||||||
|
--command 'cd srv; return'
|
||||||
srv.shell.prod:
|
|
||||||
nix-shell -A srv.shell --arg baseConfig '(import ./prod.config.nix)' --command 'cd srv; return'
|
|
||||||
|
|
||||||
static.shell:
|
|
||||||
nix-shell -A static.shell --command 'cd static; return'
|
|
||||||
|
|
||||||
|
# TODO static is on the way out, these aren't well supported
|
||||||
static.serve:
|
static.serve:
|
||||||
nix-shell -A static.shell --run 'cd static; static-serve'
|
nix-shell -A static.shell --run 'cd static; static-serve'
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
|
|
||||||
pkgs ? import (fetchTarball {
|
pkgsArg ? import (fetchTarball {
|
||||||
name = "nixpkgs-21-05";
|
name = "nixpkgs-21-05";
|
||||||
url = "https://github.com/NixOS/nixpkgs/archive/7e9b0dff974c89e070da1ad85713ff3c20b0ca97.tar.gz";
|
url = "https://github.com/NixOS/nixpkgs/archive/7e9b0dff974c89e070da1ad85713ff3c20b0ca97.tar.gz";
|
||||||
sha256 = "1ckzhh24mgz6jd1xhfgx0i9mijk6xjqxwsshnvq789xsavrmsc36";
|
sha256 = "1ckzhh24mgz6jd1xhfgx0i9mijk6xjqxwsshnvq789xsavrmsc36";
|
||||||
@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
}: rec {
|
}: rec {
|
||||||
|
|
||||||
|
pkgs = pkgsArg;
|
||||||
|
|
||||||
config = baseConfig // {
|
config = baseConfig // {
|
||||||
redisListenPath = "${config.runDir}/redis";
|
redisListenPath = "${config.runDir}/redis";
|
||||||
};
|
};
|
||||||
|
@ -63,4 +63,12 @@
|
|||||||
cd src
|
cd src
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
test = stdenv.mkDerivation {
|
||||||
|
name = "mediocre-blog-srv-test";
|
||||||
|
buildInputs = [ go ];
|
||||||
|
shellHook = ''
|
||||||
|
source ${init}
|
||||||
|
'';
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
23
test.sh
Normal file
23
test.sh
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
|
||||||
|
test_dir="$(mktemp -d)"
|
||||||
|
|
||||||
|
mkdir -p "$test_dir"/run
|
||||||
|
mkdir -p "$test_dir"/data
|
||||||
|
|
||||||
|
test_cfg="(import ./config.nix) // {
|
||||||
|
runDir=\"${test_dir}/run\";
|
||||||
|
dataDir=\"${test_dir}/data\";
|
||||||
|
}"
|
||||||
|
|
||||||
|
$(nix-build --no-out-link -A entrypoint \
|
||||||
|
--arg baseConfig "$test_cfg" \
|
||||||
|
--arg baseSkipServices '["srv" "static"]') &
|
||||||
|
|
||||||
|
trap "kill $!; wait; rm -rf $test_dir" EXIT
|
||||||
|
|
||||||
|
# TODO there's a race condition here, we should wait until redis is definitely
|
||||||
|
# listening before commencing the tests.
|
||||||
|
|
||||||
|
nix-shell -A srv.test \
|
||||||
|
--arg baseConfig "$test_cfg" \
|
||||||
|
--run "cd srv/src && go test ./... -count=1 -tags integration"
|
Loading…
Reference in New Issue
Block a user