Commit e1b59f78 authored by Felix Buehler's avatar Felix Buehler
Browse files

nixos/homer: add tests

parent 4cff6cd1
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -436,6 +436,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 {});
+30 −0
Original line number Diff line number Diff line
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 −0
Original line number Diff line number Diff line
{ system, pkgs, ... }:

{
  caddy = import ./caddy.nix { inherit system pkgs; };
  nginx = import ./nginx.nix { inherit system pkgs; };
}
+30 −0
Original line number Diff line number Diff line
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'")
    '';
  }
)
+7 −1
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@
  nodejs,
  dart-sass,
  nix-update-script,
  nixosTests,
}:
stdenvNoCC.mkDerivation rec {
  pname = "homer";
@@ -54,7 +55,12 @@ stdenvNoCC.mkDerivation rec {
    runHook postInstall
  '';

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

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