summaryrefslogtreecommitdiff
path: root/tests/travelynx.nix
blob: d15899eec3f58f1024bc4cb29d6c551073977ef4 (plain)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
{
  name = "travelynx-prove-test-suite";

  nodes.travelynx = { config, pkgs, ... }: {

    services.postgresql = {
      enable = true;
      ensureDatabases = [ "travelynx" ];
      ensureUsers = [{
        name = "travelynx";
        ensureDBOwnership = true;
      }];
      authentication = ''
        host  all  all  ::1/127  trust
      '';
    };

    environment.etc."/travelynx".source = pkgs.travelynx;

    environment.etc."/travelynx.conf".text = ''
      {
        base_url => Mojo::URL->new('http://localhost'),

        cache => {
          schedule => './var/cache/travelynx/iris',
          realtime => './var/cache/travelynx/iris-rt',
        },

        db => {
          host => 'localhost',
          port => 5432,
          database => 'travelynx',
          user => 'travelynx',
        },

        hypnotoad => {
          accepts  => 100,
          clients  => 10,
          listen   => [ 'http://127.0.0.1:8093' ],
          pid_file => '/tmp/travelynx.pid',
          workers  => 2,
          spare    => 2,
        },

        mail => {
          disabled => 1,
        },

        ref => {
          issues => 'https://github.com/derf/travelynx/issues',
          source => 'https://github.com/derf/travelynx',
        },

        secrets => [
          "secret"
        ],

        version => 'vm-test',
      };
    '';

    environment.systemPackages = [ pkgs.travelynx.perl ];
  };

  testScript = ''
    machine.start()
    machine.wait_for_unit("postgresql.service")

    machine.succeed("cp -r /etc/travelynx/* .")
    machine.succeed("chmod +w -R .")
    machine.succeed("cp /etc/travelynx.conf .")

    machine.succeed("./index.pl database migrate")

    # this executes travelynx's own test suite, which requires a working database
    # & networking, hence i didn't put it into the package's test phase
    # (also, it seems to be failing?)
    machine.succeed("prove")
  '';
}