open-webui: test environmentFile option

Modify the tests for open-webui such that the name of the service
is set via the 'environmentFile' option, then check that the
service's name differs from the default.
This commit is contained in:
Andrew Morgan 2024-08-15 12:08:46 +01:00
parent 67eb12c0ed
commit 908c5df932

View File

@ -1,6 +1,7 @@
{ lib, ... }:
{ config, lib, ... }:
let
mainPort = "8080";
webuiName = "NixOS Test";
in
{
name = "open-webui";
@ -18,16 +19,31 @@ in
# Requires network connection
RAG_EMBEDDING_MODEL = "";
};
# Test that environment variables can be
# overridden through a file.
environmentFile = config.node.pkgs.writeText "test.env" ''
WEBUI_NAME="${webuiName}"
'';
};
};
};
testScript = ''
import json
machine.start()
machine.wait_for_unit("open-webui.service")
machine.wait_for_open_port(${mainPort})
machine.succeed("curl http://127.0.0.1:${mainPort}")
# Load the Web UI config JSON and parse it.
webui_config_json = machine.succeed("curl http://127.0.0.1:${mainPort}/api/config")
webui_config = json.loads(webui_config_json)
# Check that the name was overridden via the environmentFile option.
assert webui_config["name"] == "${webuiName} (Open WebUI)"
'';
}