forked from Fediversity/Fediversity
collapse VM tests into one, use subtests
This commit is contained in:
parent
f4ebf55a15
commit
df9ce821de
1 changed files with 17 additions and 30 deletions
|
@ -22,43 +22,30 @@ let
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
lib.mapAttrs (name: test: pkgs.testers.runNixOSTest (test // { inherit name; })) {
|
lib.mapAttrs (name: test: pkgs.testers.runNixOSTest (test // { inherit name; })) {
|
||||||
application-tests = {
|
basic = {
|
||||||
inherit defaults;
|
|
||||||
nodes.server = _: { imports = [ ./configuration.nix ]; };
|
|
||||||
# run all application-level tests managed by Django
|
|
||||||
# https://docs.djangoproject.com/en/5.0/topics/testing/overview/
|
|
||||||
testScript = ''
|
|
||||||
server.wait_for_unit("${name}.service")
|
|
||||||
server.succeed("manage test ${name}")
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
admin = {
|
|
||||||
inherit defaults;
|
|
||||||
nodes.server = _: { imports = [ ./configuration.nix ]; };
|
|
||||||
# check that the admin interface is served
|
|
||||||
testScript = ''
|
|
||||||
server.wait_for_unit("${name}.service")
|
|
||||||
server.wait_for_open_port(8000)
|
|
||||||
server.succeed("curl --fail -L -H 'Host: example.org' http://localhost/admin")
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
sass-processing = {
|
|
||||||
inherit defaults;
|
inherit defaults;
|
||||||
nodes.server = _: { imports = [ ./configuration.nix ]; };
|
nodes.server = _: { imports = [ ./configuration.nix ]; };
|
||||||
extraPythonPackages = ps: with ps; [ beautifulsoup4 ];
|
extraPythonPackages = ps: with ps; [ beautifulsoup4 ];
|
||||||
# type checking on `beautifulsoup4` will error out
|
# type checking on `beautifulsoup4` will error out
|
||||||
skipTypeCheck = true;
|
skipTypeCheck = true;
|
||||||
# check that stylesheets are pre-processed and served
|
|
||||||
testScript = ''
|
testScript = ''
|
||||||
from bs4 import BeautifulSoup
|
|
||||||
server.wait_for_unit("${name}.service")
|
server.wait_for_unit("${name}.service")
|
||||||
server.wait_for_open_port(8000)
|
|
||||||
|
with subtest("Django application tests"):
|
||||||
|
# https://docs.djangoproject.com/en/5.0/topics/testing/overview/
|
||||||
|
server.succeed("manage test ${name}")
|
||||||
|
|
||||||
|
with subtest("Check that admin interface is served"):
|
||||||
|
server.succeed("curl --fail -L -H 'Host: example.org' http://localhost/admin")
|
||||||
|
|
||||||
|
with subtest("Check that stylesheets are pre-processed and served"):
|
||||||
|
from bs4 import BeautifulSoup
|
||||||
stdout = server.succeed("curl --fail -H 'Host: example.org' http://localhost")
|
stdout = server.succeed("curl --fail -H 'Host: example.org' http://localhost")
|
||||||
# the CSS is auto-generated with a hash in the file name
|
# the CSS is auto-generated with a hash in the file name
|
||||||
html = BeautifulSoup(stdout, 'html.parser')
|
html = BeautifulSoup(stdout, 'html.parser')
|
||||||
css = html.find('link', type="text/css")['href']
|
css = html.find('link', type="text/css")['href']
|
||||||
server.succeed(f"curl --fail -H 'Host: example.org' http://localhost/{css}")
|
server.succeed(f"curl --fail -H 'Host: example.org' http://localhost/{css}")
|
||||||
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue