Skip to content

Commit

Permalink
nixos/homer: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Stunkymonkey committed Jan 9, 2025
1 parent 7a1721a commit bf80a77
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 1 deletion.
1 change: 1 addition & 0 deletions nixos/tests/all-tests.nix
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ in {
hedgedoc = handleTest ./hedgedoc.nix {};
herbstluftwm = handleTest ./herbstluftwm.nix {};
homebox = handleTest ./homebox.nix {};
homer = handleTest ./homer {};
homepage-dashboard = handleTest ./homepage-dashboard.nix {};
honk = runTest ./honk.nix;
installed-tests = pkgs.recurseIntoAttrs (handleTest ./installed-tests {});
Expand Down
30 changes: 30 additions & 0 deletions nixos/tests/homer/caddy.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import ../make-test-python.nix (
{ lib, ... }:

{
name = "homer-caddy";
meta.maintainers = with lib.maintainers; [ stunkymonkey ];

nodes.machine =
{ pkgs, ... }:
{
services.homer = {
enable = true;
virtualHost = {
caddy.enable = true;
domain = "localhost:80";
};
settings = {
title = "testing";
};
};
};

testScript = ''
machine.wait_for_unit("caddy.service")
machine.wait_for_open_port(80)
machine.succeed("curl --fail --show-error --silent http://localhost:80/ | grep '<title>Homer</title>'")
machine.succeed("curl --fail --show-error --silent http://localhost:80/assets/config.yml | grep 'title: testing'")
'';
}
)
6 changes: 6 additions & 0 deletions nixos/tests/homer/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{ system, pkgs, ... }:

{
caddy = import ./caddy.nix { inherit system pkgs; };
nginx = import ./nginx.nix { inherit system pkgs; };
}
30 changes: 30 additions & 0 deletions nixos/tests/homer/nginx.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import ../make-test-python.nix (
{ lib, ... }:

{
name = "homer-nginx";
meta.maintainers = with lib.maintainers; [ stunkymonkey ];

nodes.machine =
{ pkgs, ... }:
{
services.homer = {
enable = true;
virtualHost = {
nginx.enable = true;
domain = "localhost";
};
settings = {
title = "testing";
};
};
};

testScript = ''
machine.wait_for_unit("nginx.service")
machine.wait_for_open_port(80)
machine.succeed("curl --fail --show-error --silent http://localhost:80/ | grep '<title>Homer</title>'")
machine.succeed("curl --fail --show-error --silent http://localhost:80/assets/config.yml | grep 'title: testing'")
'';
}
)
8 changes: 7 additions & 1 deletion pkgs/by-name/ho/homer/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
nodejs,
dart-sass,
nix-update-script,
nixosTests,
}:
stdenvNoCC.mkDerivation rec {
pname = "homer";
Expand Down Expand Up @@ -54,7 +55,12 @@ stdenvNoCC.mkDerivation rec {
runHook postInstall
'';

passthru.updateScript = nix-update-script { };
passthru = {
updateScript = nix-update-script { };
tests = {
inherit (nixosTests) homer;
};
};

meta = with lib; {
description = "A very simple static homepage for your server.";
Expand Down

0 comments on commit bf80a77

Please sign in to comment.