about summary refs log tree commit diff
path: root/nixos/tests/nzbget.nix
blob: e45031d5629c43e3e4b713085510f333aed6116d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import ./make-test-python.nix ({ pkgs, ...} : {
  name = "nzbget";
  meta = with pkgs.lib.maintainers; {
    maintainers = [ aanderse flokli ];
  };

  nodes = {
    server = { ... }: {
      services.nzbget.enable = true;

      # provide some test settings
      services.nzbget.settings = {
        "MainDir" = "/var/lib/nzbget";
        "DirectRename" = true;
        "DiskSpace" = 0;
        "Server1.Name" = "this is a test";
      };

      # hack, don't add (unfree) unrar to nzbget's path,
      # so we can run this test in CI
      systemd.services.nzbget.path = pkgs.lib.mkForce [ pkgs.p7zip ];
    };
  };

  testScript = { nodes, ... }: ''
    start_all()

    server.wait_for_unit("nzbget.service")
    server.wait_for_unit("network.target")
    server.wait_for_open_port(6789)
    assert "This file is part of nzbget" in server.succeed(
        "curl -f -s -u nzbget:tegbzn6789 http://127.0.0.1:6789"
    )
    server.succeed(
        "${pkgs.nzbget}/bin/nzbget -n -o Control_iP=127.0.0.1 -o Control_port=6789 -o Control_password=tegbzn6789 -V"
    )

    config = server.succeed("${nodes.server.systemd.services.nzbget.serviceConfig.ExecStart} --printconfig")

    # confirm the test settings are applied
    assert 'MainDir = "/var/lib/nzbget"' in config
    assert 'DirectRename = "yes"' in config
    assert 'DiskSpace = "0"' in config
    assert 'Server1.Name = "this is a test"' in config
  '';
})