3
0
Fork 0
forked from mirrors/nixpkgs

nixos/netbox: add nixos test

This commit is contained in:
Ember 'n0emis' Keske 2022-03-06 17:02:14 +01:00
parent dbd49febb5
commit 313b1dc9d0
No known key found for this signature in database
GPG key ID: 00FAF748B777CF10
3 changed files with 36 additions and 0 deletions

View file

@ -341,6 +341,7 @@ in
networking.networkd = handleTest ./networking.nix { networkd = true; };
networking.scripted = handleTest ./networking.nix { networkd = false; };
specialisation = handleTest ./specialisation.nix {};
netbox = handleTest ./web-apps/netbox.nix {};
# TODO: put in networking.nix after the test becomes more complete
networkingProxy = handleTest ./networking-proxy.nix {};
nextcloud = handleTest ./nextcloud {};

View file

@ -0,0 +1,30 @@
import ../make-test-python.nix ({ lib, pkgs, ... }: {
name = "netbox";
meta = with lib.maintainers; {
maintainers = [ n0emis ];
};
machine = { ... }: {
services.netbox = {
enable = true;
secretKeyFile = pkgs.writeText "secret" ''
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
'';
};
};
testScript = ''
machine.start()
machine.wait_for_unit("netbox.target")
machine.wait_until_succeeds("journalctl --since -1m --unit netbox --grep Listening")
with subtest("Home screen loads"):
machine.succeed(
"curl -sSfL http://[::1]:8001 | grep '<title>Home | NetBox</title>'"
)
with subtest("Staticfiles are generated"):
machine.succeed("test -e /var/lib/netbox/static/netbox.js")
'';
})

View file

@ -1,6 +1,7 @@
{ lib
, pkgs
, fetchFromGitHub
, nixosTests
, python3
, plugins ? ps: [] }:
@ -101,6 +102,10 @@ py.pkgs.buildPythonApplication rec {
passthru = {
# PYTHONPATH of all dependencies used by the package
pythonPath = python3.pkgs.makePythonPath propagatedBuildInputs;
tests = {
inherit (nixosTests) netbox;
};
};
meta = with lib; {