added tests
This commit is contained in:
parent
14d83dafcd
commit
8005ad1ccc
24
flake.nix
24
flake.nix
|
@ -9,11 +9,28 @@
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
forAllSystems = nixpkgs.lib.genAttrs [
|
forAllSystems = nixpkgs.lib.genAttrs [
|
||||||
"aarch64-linux"
|
|
||||||
"x86_64-linux"
|
"x86_64-linux"
|
||||||
"x86_64-darwin"
|
"x86_64-darwin"
|
||||||
|
"aarch64-linux"
|
||||||
"aarch64-darwin"
|
"aarch64-darwin"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
# Create a test for every file in `tests/`
|
||||||
|
tests = system:
|
||||||
|
builtins.listToAttrs (builtins.map
|
||||||
|
(x: let
|
||||||
|
test = import (./tests + "/${x}") {pkgs = import nixpkgs {inherit system;};};
|
||||||
|
in {
|
||||||
|
name = test.name;
|
||||||
|
value = test.test;
|
||||||
|
})
|
||||||
|
(
|
||||||
|
builtins.filter (x: x != null) ((nixpkgs.lib.attrsets.mapAttrsToList (name: value:
|
||||||
|
if value == "regular"
|
||||||
|
then name
|
||||||
|
else null))
|
||||||
|
(builtins.readDir ./tests))
|
||||||
|
));
|
||||||
in {
|
in {
|
||||||
formatter = forAllSystems (
|
formatter = forAllSystems (
|
||||||
system: let
|
system: let
|
||||||
|
@ -25,6 +42,9 @@
|
||||||
declarative-jellyfin = import ./modules;
|
declarative-jellyfin = import ./modules;
|
||||||
default = declarative-jellyfin;
|
default = declarative-jellyfin;
|
||||||
};
|
};
|
||||||
nixosModule = self.nixosModules.default; # compatiblilty
|
|
||||||
|
# Run all tests for all systems
|
||||||
|
hydraJobs = forAllSystems tests;
|
||||||
|
checks = forAllSystems tests;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
{nixpkgs, ...}:
|
{ nixpkgs, ... }:
|
||||||
nixpkgs.lib.extend (
|
{
|
||||||
final: prev: {
|
toXMLGeneric =
|
||||||
toXMLGeneric = let
|
let
|
||||||
toXMLRecursive =
|
toXMLRecursive =
|
||||||
toXmlRecursive'
|
toXmlRecursive'
|
||||||
"<?xml version='1.0' encoding='utf-8'?>\n"
|
"<?xml version='1.0' encoding='utf-8'?>\n"
|
||||||
0;
|
0;
|
||||||
|
|
||||||
indent = depth: (
|
indent = depth: (
|
||||||
if (depth <= 0)
|
if (depth <= 0)
|
||||||
|
@ -13,33 +13,33 @@ nixpkgs.lib.extend (
|
||||||
else (" " + (indent (depth - 1)))
|
else (" " + (indent (depth - 1)))
|
||||||
);
|
);
|
||||||
|
|
||||||
toXmlRecursive' = str: depth: xml: let
|
toXmlRecursive' = str: depth: xml:
|
||||||
# depth = if (builtins.isInt depth) then depth else (throw "DEPTH ISNT AN INT??? WTFFF");
|
let
|
||||||
parseTag = str: depth: xml: (builtins.concatStringsSep "" [
|
parseTag = str: depth: xml: (builtins.concatStringsSep "" [
|
||||||
str
|
str
|
||||||
"${indent depth}<${xml.name}${
|
"${indent depth}<${xml.name}${
|
||||||
if (builtins.hasAttr "content" xml)
|
if (builtins.hasAttr "content" xml)
|
||||||
then ">"
|
then ">"
|
||||||
else " "
|
else " "
|
||||||
}"
|
}"
|
||||||
|
|
||||||
(
|
(
|
||||||
if (builtins.hasAttr "properties" xml)
|
if (builtins.hasAttr "properties" xml)
|
||||||
then
|
then
|
||||||
(" "
|
(" "
|
||||||
+ builtins.concatStringsSep " " (nixpkgs.lib.attrsets.mapAttrsToList
|
+ builtins.concatStringsSep " " (nixpkgs.lib.attrsets.mapAttrsToList
|
||||||
(name: value: "${name}=\"${nixpkgs.lib.strings.escapeXML value}\"")
|
(name: value: "${name}=\"${nixpkgs.lib.strings.escapeXML value}\"")
|
||||||
xml.properties))
|
xml.properties))
|
||||||
else ""
|
else ""
|
||||||
)
|
)
|
||||||
|
|
||||||
(
|
(
|
||||||
if builtins.hasAttr "content" xml
|
if builtins.hasAttr "content" xml
|
||||||
then ((toXmlRecursive' "\n" (depth + 1) xml.content) + "</${xml.name}>")
|
then ((toXmlRecursive' "\n" (depth + 1) xml.content) + "</${xml.name}>")
|
||||||
else "/>"
|
else "/>"
|
||||||
)
|
)
|
||||||
]);
|
]);
|
||||||
in
|
in
|
||||||
if (builtins.isAttrs xml)
|
if (builtins.isAttrs xml)
|
||||||
then "${parseTag str depth xml}\n${indent (depth - 1)}"
|
then "${parseTag str depth xml}\n${indent (depth - 1)}"
|
||||||
else if (builtins.isList xml)
|
else if (builtins.isList xml)
|
||||||
|
@ -50,6 +50,6 @@ nixpkgs.lib.extend (
|
||||||
then xml
|
then xml
|
||||||
else throw "Cannot convert a ${builtins.typeOf xml} to XML";
|
else throw "Cannot convert a ${builtins.typeOf xml} to XML";
|
||||||
in
|
in
|
||||||
toXMLRecursive;
|
toXMLRecursive;
|
||||||
}
|
}
|
||||||
)
|
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
{...}: {
|
{...}: {
|
||||||
imports = [./.];
|
imports = [
|
||||||
|
./config.nix
|
||||||
|
./options
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
{
|
{
|
||||||
config,
|
config,
|
||||||
lib,
|
nixpkgs,
|
||||||
pkgs,
|
pkgs,
|
||||||
|
lib,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
cfg = config.services.declarative-jellyfin;
|
cfg = config.services.declarative-jellyfin;
|
||||||
|
toXml = (import ../../lib {inherit nixpkgs;}).toXMLGeneric;
|
||||||
in
|
in
|
||||||
with lib; {
|
with lib; {
|
||||||
imports = [
|
imports = [
|
||||||
|
@ -36,7 +38,7 @@ in
|
||||||
else (listOfStrPrepass value)
|
else (listOfStrPrepass value)
|
||||||
)
|
)
|
||||||
xml));
|
xml));
|
||||||
toXml = name: x: (toXMLGeneric {
|
toXml = name: x: (toXml {
|
||||||
inherit name;
|
inherit name;
|
||||||
properties = {
|
properties = {
|
||||||
"xmlns:xsi" = "http://www.w3.org/2001/XMLSchema-instance";
|
"xmlns:xsi" = "http://www.w3.org/2001/XMLSchema-instance";
|
||||||
|
|
26
tests/minimal.nix
Normal file
26
tests/minimal.nix
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
{pkgs ? import <nixpkgs> {}, ...}: let
|
||||||
|
name = "minimal";
|
||||||
|
in {
|
||||||
|
inherit name;
|
||||||
|
test = pkgs.nixosTest {
|
||||||
|
inherit name;
|
||||||
|
nodes = {
|
||||||
|
machine = {
|
||||||
|
config,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}: {
|
||||||
|
imports = [
|
||||||
|
../modules/default.nix
|
||||||
|
];
|
||||||
|
|
||||||
|
virtualisation.memorySize = 1024;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
testScript = ''
|
||||||
|
machine.start()
|
||||||
|
machine.wait_for_unit("multi-user.target");
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue