who added the formatting test my commits keep failing it smh
All checks were successful
Run tests / run_tests (push) Successful in 51s

This commit is contained in:
Snorre 2025-04-05 23:25:13 +02:00
parent fa91487a1f
commit aec76d9b86
2 changed files with 149 additions and 142 deletions

View file

@ -45,8 +45,11 @@
then (builtins.toString xml) then (builtins.toString xml)
else if (builtins.isString xml) else if (builtins.isString xml)
then xml then xml
else if (builtins.isBool xml)then else if (builtins.isBool xml)
if xml then "true" else "false" then
if xml
then "true"
else "false"
else throw "Cannot convert a ${builtins.typeOf xml} to XML. ${toString (builtins.trace xml xml)}"; else throw "Cannot convert a ${builtins.typeOf xml} to XML. ${toString (builtins.trace xml xml)}";
in in
toXMLRecursive; toXMLRecursive;

View file

@ -1,153 +1,157 @@
{ pkgs ? import <nixpkgs> { }, ... }: {pkgs ? import <nixpkgs> {}, ...}: let
let
name = "networking"; name = "networking";
in in {
{
inherit name; inherit name;
test = pkgs.nixosTest { test = pkgs.nixosTest {
inherit name; inherit name;
nodes = { nodes = {
machine = machine = {
{ config config,
, pkgs pkgs,
, ... ...
}: { }: {
imports = [ imports = [
../modules/default.nix ../modules/default.nix
]; ];
# assertions = let # assertions = let
# toXml = (import ../lib {nixpkgs = pkgs;}).toXMLGeneric; # toXml = (import ../lib {nixpkgs = pkgs;}).toXMLGeneric;
# in [ # in [
# ( # (
# let # let
# xml = # xml =
# toXml {tag = "test";}; # toXml {tag = "test";};
# expected = '' # expected = ''
# <?xml version='1.0' encoding='utf-8'?> # <?xml version='1.0' encoding='utf-8'?>
# <test /> # <test />
# ''; # '';
# in { # in {
# assertion = xml == expected; # assertion = xml == expected;
# message = "Generated XML is incorrect!\nExpected \n\n${expected}\n\n but got \n\n${xml}\n"; # message = "Generated XML is incorrect!\nExpected \n\n${expected}\n\n but got \n\n${xml}\n";
# } # }
# ) # )
# ]; # ];
assertions = assertions = let
let genTest = name: expected: got: {
genTest = name: expected: got: { assertion = expected == got;
assertion = expected == got; message = "[Test: ${name}] Generated XML is incorrect!\nExpected \n\n${expected}\n but got \n\n${got}";
message = "[Test: ${name}] Generated XML is incorrect!\nExpected \n\n${expected}\n but got \n\n${got}"; };
}; toXml = (import ../lib {nixpkgs = pkgs;}).toXMLGeneric;
toXml = (import ../lib { nixpkgs = pkgs; }).toXMLGeneric; in [
in (
[ genTest "Single tag"
(genTest "Single tag" ''
'' <?xml version='1.0' encoding='utf-8'?>
<?xml version='1.0' encoding='utf-8'?> <test />
<test /> ''
'' (toXml {tag = "test";})
(toXml { tag = "test"; }) )
) (
(genTest "Single inner tag" genTest "Single inner tag"
'' ''
<?xml version='1.0' encoding='utf-8'?> <?xml version='1.0' encoding='utf-8'?>
<test> <test>
<inner /> <inner />
</test> </test>
'' ''
(toXml { (toXml {
tag = "test"; tag = "test";
content = { tag = "inner"; }; content = {tag = "inner";};
}) })
) )
(genTest "Tag with string" (
'' genTest "Tag with string"
<?xml version='1.0' encoding='utf-8'?> ''
<test>stringstringstring</test> <?xml version='1.0' encoding='utf-8'?>
'' <test>stringstringstring</test>
(toXml { ''
tag = "test"; (toXml {
content = "stringstringstring"; tag = "test";
}) content = "stringstringstring";
) })
(genTest "Empty string" )
'' (
<?xml version='1.0' encoding='utf-8'?> genTest "Empty string"
<test /> ''
'' <?xml version='1.0' encoding='utf-8'?>
(toXml { <test />
tag = "test"; ''
content = ""; (toXml {
}) tag = "test";
) content = "";
(genTest "List of tags" })
'' )
<?xml version='1.0' encoding='utf-8'?> (
<test> genTest "List of tags"
<tag0 /> ''
<tag1 /> <?xml version='1.0' encoding='utf-8'?>
<tag2 /> <test>
<tag3 /> <tag0 />
<tag4 /> <tag1 />
<tag5 /> <tag2 />
<tag6 /> <tag3 />
<tag7 /> <tag4 />
<tag8 /> <tag5 />
</test> <tag6 />
'' <tag7 />
(toXml { <tag8 />
tag = "test"; </test>
content = builtins.genList (x: { tag = "tag${toString x}"; }) 9; ''
}) (toXml {
) tag = "test";
(genTest "Empty list" content = builtins.genList (x: {tag = "tag${toString x}";}) 9;
'' })
<?xml version='1.0' encoding='utf-8'?> )
<test /> (
'' genTest "Empty list"
(toXml { ''
tag = "test"; <?xml version='1.0' encoding='utf-8'?>
content = [ ]; <test />
}) ''
) (toXml {
(genTest "bool value true" tag = "test";
'' content = [];
<?xml version='1.0' encoding='utf-8'?> })
<test>true</test> )
'' (
(toXml { genTest "bool value true"
tag = "test"; ''
content = true; <?xml version='1.0' encoding='utf-8'?>
}) <test>true</test>
) ''
(genTest "bool value false" (toXml {
'' tag = "test";
<?xml version='1.0' encoding='utf-8'?> content = true;
<test>false</test> })
'' )
(toXml { (
tag = "test"; genTest "bool value false"
content = false; ''
}) <?xml version='1.0' encoding='utf-8'?>
) <test>false</test>
''
(toXml {
tag = "test";
content = false;
})
)
];
virtualisation.memorySize = 1024;
services.declarative-jellyfin = {
enable = true;
network = {
PublishedServerUriBySubnet = [
"all=https://test.test.test"
]; ];
EnableHttps = true;
virtualisation.memorySize = 1024; RequireHttps = true;
CertificatePath = "/path/to/cert";
services.declarative-jellyfin = {
enable = true;
network = {
PublishedServerUriBySubnet = [
"all=https://test.test.test"
];
EnableHttps = true;
RequireHttps = true;
CertificatePath = "/path/to/cert";
};
}; };
}; };
};
}; };
testScript = '' testScript = ''