declarative-jellyfin/tests/xml.nix
Snorre Ettrup Altschul 33a30b1d2a
Some checks failed
Run tests / run_tests (push) Failing after 3s
fixed shit
2025-04-04 00:53:14 +02:00

74 lines
1.9 KiB
Nix

{pkgs ? import <nixpkgs> {}, ...}: let
name = "networking";
in {
inherit name;
test = pkgs.nixosTest {
inherit name;
nodes = {
machine = {
config,
pkgs,
...
}: {
imports = [
../modules/default.nix
];
assertions = let
toXml = (import ../lib {nixpkgs = pkgs;}).toXMLGeneric;
in [
(
let
xml =
toXml {tag = "test";};
expected = ''
<?xml version='1.0' encoding='utf-8'?>
<test />
'';
in {
assertion = xml == expected;
message = "Generated XML is incorrect!\nExpected \n\n${expected}\n\n but got \n\n${xml}\n";
}
)
];
virtualisation.memorySize = 1024 * 2;
services.declarative-jellyfin = {
enable = true;
network = {
PublishedServerUriBySubnet = [
"all=https://test.test.test"
];
};
};
};
};
testScript = ''
import xml.etree.ElementTree as ET
machine.wait_for_unit("multi-user.target");
with subtest("Networking"):
# stupid fucking hack because you cant open files in python for some reason
xml = machine.succeed("cat /var/lib/jellyfin/config/network.xml")
tree = ET.ElementTree(ET.fromstring(xml))
root = tree.getroot()
for child in root:
if child.tag == "PublishedServerUriBySubnet":
try:
if child[0].text == "all=https://test.test.test":
break
except:
print("An error occured when trying to parse xml")
print(xml)
assert False, "Exception occured, check output above"
else:
assert False, "The shit was not found"
machine.shutdown()
'';
};
}