Skip to content

Commit

Permalink
nixos/tests/immich: init tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jvanbruegge committed Aug 11, 2024
1 parent fc0e684 commit 1964ff4
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions nixos/tests/all-tests.nix
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ in {
icingaweb2 = handleTest ./icingaweb2.nix {};
ifm = handleTest ./ifm.nix {};
iftop = handleTest ./iftop.nix {};
immich = handleTest ./web-apps/immich.nix {};
incron = handleTest ./incron.nix {};
incus = pkgs.recurseIntoAttrs (handleTest ./incus { inherit handleTestOn; inherit (pkgs) incus; });
incus-lts = pkgs.recurseIntoAttrs (handleTest ./incus { inherit handleTestOn; });
Expand Down
51 changes: 51 additions & 0 deletions nixos/tests/web-apps/immich.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import ../make-test-python.nix (
{ ... }:
{
name = "immich-nixos";

nodes.machine =
{ pkgs, ... }:
{
# These tests need a little more juice
virtualisation = {
cores = 2;
memorySize = 2048;
diskSize = 4096;
};

environment.systemPackages = with pkgs; [ immich.cli ];

services.immich = {
enable = true;
environment.IMMICH_LOG_LEVEL = "verbose";
};
};

testScript = ''
import json
machine.wait_for_unit("immich-server.service")
machine.wait_for_open_port(3001) # Server
machine.wait_for_open_port(3003) # Machine learning
machine.succeed("curl --fail http://localhost:3001/")
machine.succeed("""
curl -H 'Content-Type: application/json' --data '{ "email": "test@example.com", "name": "Admin", "password": "admin" }' -X POST http://localhost:3001/api/auth/admin-sign-up
""")
res = machine.succeed("""
curl -H 'Content-Type: application/json' --data '{ "email": "test@example.com", "password": "admin" }' -X POST http://localhost:3001/api/auth/login
""")
token = json.loads(res)['accessToken']
res = machine.succeed("""
curl -H 'Content-Type: application/json' -H 'Cookie: immich_access_token=%s' --data '{ "name": "API Key" }' -X POST http://localhost:3001/api/api-keys
""" % token)
key = json.loads(res)['secret']
machine.succeed(f"immich login http://localhost:3001/api {key}")
res = machine.succeed("immich server-info")
print(res)
'';
}
)

0 comments on commit 1964ff4

Please sign in to comment.