From aec76d9b86bc19c788b910d026cf806815f48a2f Mon Sep 17 00:00:00 2001 From: Snorre Date: Sat, 5 Apr 2025 23:25:13 +0200 Subject: [PATCH] who added the formatting test my commits keep failing it smh --- lib/default.nix | 7 +- tests/xml.nix | 284 ++++++++++++++++++++++++------------------------ 2 files changed, 149 insertions(+), 142 deletions(-) diff --git a/lib/default.nix b/lib/default.nix index 759cc8d..7c08055 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -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; diff --git a/tests/xml.nix b/tests/xml.nix index 9b5c6ce..34edb49 100644 --- a/tests/xml.nix +++ b/tests/xml.nix @@ -1,153 +1,157 @@ -{ pkgs ? import { }, ... }: -let +{pkgs ? import {}, ...}: 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 = '' - # - # - # ''; - # 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 = '' + # + # + # ''; + # 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" - '' - - - '' - (toXml { tag = "test"; }) - ) - (genTest "Single inner tag" - '' - - - - - '' - (toXml { - tag = "test"; - content = { tag = "inner"; }; - }) - ) - (genTest "Tag with string" - '' - - stringstringstring - '' - (toXml { - tag = "test"; - content = "stringstringstring"; - }) - ) - (genTest "Empty string" - '' - - - '' - (toXml { - tag = "test"; - content = ""; - }) - ) - (genTest "List of tags" - '' - - - - - - - - - - - - - '' - (toXml { - tag = "test"; - content = builtins.genList (x: { tag = "tag${toString x}"; }) 9; - }) - ) - (genTest "Empty list" - '' - - - '' - (toXml { - tag = "test"; - content = [ ]; - }) - ) - (genTest "bool value true" - '' - - true - '' - (toXml { - tag = "test"; - content = true; - }) - ) - (genTest "bool value false" - '' - - false - '' - (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" + '' + + + '' + (toXml {tag = "test";}) + ) + ( + genTest "Single inner tag" + '' + + + + + '' + (toXml { + tag = "test"; + content = {tag = "inner";}; + }) + ) + ( + genTest "Tag with string" + '' + + stringstringstring + '' + (toXml { + tag = "test"; + content = "stringstringstring"; + }) + ) + ( + genTest "Empty string" + '' + + + '' + (toXml { + tag = "test"; + content = ""; + }) + ) + ( + genTest "List of tags" + '' + + + + + + + + + + + + + '' + (toXml { + tag = "test"; + content = builtins.genList (x: {tag = "tag${toString x}";}) 9; + }) + ) + ( + genTest "Empty list" + '' + + + '' + (toXml { + tag = "test"; + content = []; + }) + ) + ( + genTest "bool value true" + '' + + true + '' + (toXml { + tag = "test"; + content = true; + }) + ) + ( + genTest "bool value false" + '' + + false + '' + (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 = ''