summaryrefslogtreecommitdiffstats
path: root/nixos/tests/lavalink.nix
blob: 878f05094190f840aac1c252a21a7cfe52b7edc3 (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
{ lib, ... }:

let
  password = "s3cRe!p4SsW0rD";
in

{
  name = "lavalink";
  meta.maintainers = with lib.maintainers; [ nanoyaki ];

  nodes = {
    machine = {
      services.lavalink = {
        enable = true;
        port = 1234;
        inherit password;
      };
    };
    machine2 =
      { pkgs, ... }:
      {
        services.lavalink = {
          enable = true;
          port = 1235;
          environmentFile = "${pkgs.writeText "passwordEnvFile" ''
            LAVALINK_SERVER_PASSWORD=${password}
          ''}";
        };
      };
  };

  testScript = ''
    start_all()

    machine.wait_for_unit("lavalink.service")
    machine.wait_for_open_port(1234)
    machine.succeed("curl --header \"User-Id: 1204475253028429844\" --header \"Client-Name: shoukaku/4.1.1\" --header \"Authorization: ${password}\" http://localhost:1234/v4/info --fail -v")

    machine2.wait_for_unit("lavalink.service")
    machine2.wait_for_open_port(1235)
    machine2.succeed("curl --header \"User-Id: 1204475253028429844\" --header \"Client-Name: shoukaku/4.1.1\" --header \"Authorization: ${password}\" http://localhost:1235/v4/info --fail -v")
  '';
}