who added the formatting test my commits keep failing it smh
All checks were successful
Run tests / run_tests (push) Successful in 51s
All checks were successful
Run tests / run_tests (push) Successful in 51s
This commit is contained in:
parent
fa91487a1f
commit
aec76d9b86
|
@ -45,8 +45,11 @@
|
|||
then (builtins.toString xml)
|
||||
else if (builtins.isString xml)
|
||||
then xml
|
||||
else if (builtins.isBool xml)then
|
||||
if xml then "true" else "false"
|
||||
else if (builtins.isBool xml)
|
||||
then
|
||||
if xml
|
||||
then "true"
|
||||
else "false"
|
||||
else throw "Cannot convert a ${builtins.typeOf xml} to XML. ${toString (builtins.trace xml xml)}";
|
||||
in
|
||||
toXMLRecursive;
|
||||
|
|
284
tests/xml.nix
284
tests/xml.nix
|
@ -1,153 +1,157 @@
|
|||
{ pkgs ? import <nixpkgs> { }, ... }:
|
||||
let
|
||||
{pkgs ? import <nixpkgs> {}, ...}: let
|
||||
name = "networking";
|
||||
in
|
||||
{
|
||||
in {
|
||||
inherit name;
|
||||
test = pkgs.nixosTest {
|
||||
inherit name;
|
||||
nodes = {
|
||||
machine =
|
||||
{ config
|
||||
, pkgs
|
||||
, ...
|
||||
}: {
|
||||
imports = [
|
||||
../modules/default.nix
|
||||
];
|
||||
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";
|
||||
# }
|
||||
# )
|
||||
# ];
|
||||
# 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";
|
||||
# }
|
||||
# )
|
||||
# ];
|
||||
|
||||
assertions =
|
||||
let
|
||||
genTest = name: expected: got: {
|
||||
assertion = expected == got;
|
||||
message = "[Test: ${name}] Generated XML is incorrect!\nExpected \n\n${expected}\n but got \n\n${got}";
|
||||
};
|
||||
toXml = (import ../lib { nixpkgs = pkgs; }).toXMLGeneric;
|
||||
in
|
||||
[
|
||||
(genTest "Single tag"
|
||||
''
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<test />
|
||||
''
|
||||
(toXml { tag = "test"; })
|
||||
)
|
||||
(genTest "Single inner tag"
|
||||
''
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<test>
|
||||
<inner />
|
||||
</test>
|
||||
''
|
||||
(toXml {
|
||||
tag = "test";
|
||||
content = { tag = "inner"; };
|
||||
})
|
||||
)
|
||||
(genTest "Tag with string"
|
||||
''
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<test>stringstringstring</test>
|
||||
''
|
||||
(toXml {
|
||||
tag = "test";
|
||||
content = "stringstringstring";
|
||||
})
|
||||
)
|
||||
(genTest "Empty string"
|
||||
''
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<test />
|
||||
''
|
||||
(toXml {
|
||||
tag = "test";
|
||||
content = "";
|
||||
})
|
||||
)
|
||||
(genTest "List of tags"
|
||||
''
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<test>
|
||||
<tag0 />
|
||||
<tag1 />
|
||||
<tag2 />
|
||||
<tag3 />
|
||||
<tag4 />
|
||||
<tag5 />
|
||||
<tag6 />
|
||||
<tag7 />
|
||||
<tag8 />
|
||||
</test>
|
||||
''
|
||||
(toXml {
|
||||
tag = "test";
|
||||
content = builtins.genList (x: { tag = "tag${toString x}"; }) 9;
|
||||
})
|
||||
)
|
||||
(genTest "Empty list"
|
||||
''
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<test />
|
||||
''
|
||||
(toXml {
|
||||
tag = "test";
|
||||
content = [ ];
|
||||
})
|
||||
)
|
||||
(genTest "bool value true"
|
||||
''
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<test>true</test>
|
||||
''
|
||||
(toXml {
|
||||
tag = "test";
|
||||
content = true;
|
||||
})
|
||||
)
|
||||
(genTest "bool value false"
|
||||
''
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<test>false</test>
|
||||
''
|
||||
(toXml {
|
||||
tag = "test";
|
||||
content = false;
|
||||
})
|
||||
)
|
||||
assertions = let
|
||||
genTest = name: expected: got: {
|
||||
assertion = expected == got;
|
||||
message = "[Test: ${name}] Generated XML is incorrect!\nExpected \n\n${expected}\n but got \n\n${got}";
|
||||
};
|
||||
toXml = (import ../lib {nixpkgs = pkgs;}).toXMLGeneric;
|
||||
in [
|
||||
(
|
||||
genTest "Single tag"
|
||||
''
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<test />
|
||||
''
|
||||
(toXml {tag = "test";})
|
||||
)
|
||||
(
|
||||
genTest "Single inner tag"
|
||||
''
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<test>
|
||||
<inner />
|
||||
</test>
|
||||
''
|
||||
(toXml {
|
||||
tag = "test";
|
||||
content = {tag = "inner";};
|
||||
})
|
||||
)
|
||||
(
|
||||
genTest "Tag with string"
|
||||
''
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<test>stringstringstring</test>
|
||||
''
|
||||
(toXml {
|
||||
tag = "test";
|
||||
content = "stringstringstring";
|
||||
})
|
||||
)
|
||||
(
|
||||
genTest "Empty string"
|
||||
''
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<test />
|
||||
''
|
||||
(toXml {
|
||||
tag = "test";
|
||||
content = "";
|
||||
})
|
||||
)
|
||||
(
|
||||
genTest "List of tags"
|
||||
''
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<test>
|
||||
<tag0 />
|
||||
<tag1 />
|
||||
<tag2 />
|
||||
<tag3 />
|
||||
<tag4 />
|
||||
<tag5 />
|
||||
<tag6 />
|
||||
<tag7 />
|
||||
<tag8 />
|
||||
</test>
|
||||
''
|
||||
(toXml {
|
||||
tag = "test";
|
||||
content = builtins.genList (x: {tag = "tag${toString x}";}) 9;
|
||||
})
|
||||
)
|
||||
(
|
||||
genTest "Empty list"
|
||||
''
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<test />
|
||||
''
|
||||
(toXml {
|
||||
tag = "test";
|
||||
content = [];
|
||||
})
|
||||
)
|
||||
(
|
||||
genTest "bool value true"
|
||||
''
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<test>true</test>
|
||||
''
|
||||
(toXml {
|
||||
tag = "test";
|
||||
content = true;
|
||||
})
|
||||
)
|
||||
(
|
||||
genTest "bool value 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"
|
||||
];
|
||||
|
||||
virtualisation.memorySize = 1024;
|
||||
|
||||
services.declarative-jellyfin = {
|
||||
enable = true;
|
||||
network = {
|
||||
PublishedServerUriBySubnet = [
|
||||
"all=https://test.test.test"
|
||||
];
|
||||
EnableHttps = true;
|
||||
RequireHttps = true;
|
||||
CertificatePath = "/path/to/cert";
|
||||
};
|
||||
EnableHttps = true;
|
||||
RequireHttps = true;
|
||||
CertificatePath = "/path/to/cert";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
|
|
Loading…
Reference in a new issue