summaryrefslogtreecommitdiffstats
path: root/nixos/tests/typesense.nix
blob: 2d97150bcec5092e97055d227ccbe5767fdcf2ce (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
{ pkgs, ... }:
let
  testPort = 8108;
in
{
  name = "typesense";
  meta.maintainers = with pkgs.lib.maintainers; [ oddlama ];

  nodes.machine =
    { ... }:
    {
      services.typesense = {
        enable = true;
        apiKeyFile = pkgs.writeText "typesense-api-key" "dummy";
        settings.server = {
          api-port = testPort;
          api-address = "0.0.0.0";
        };
      };
    };

  testScript = ''
    machine.wait_for_unit("typesense.service")
    machine.wait_for_open_port(${toString testPort})
    # After waiting for the port, typesense still hasn't initialized the database, so wait until we can connect successfully
    assert machine.wait_until_succeeds("curl --fail http://localhost:${toString testPort}/health") == '{"ok":true}'
  '';
}