added tests
This commit is contained in:
parent
14d83dafcd
commit
8005ad1ccc
24
flake.nix
24
flake.nix
|
@ -9,11 +9,28 @@
|
|||
...
|
||||
}: let
|
||||
forAllSystems = nixpkgs.lib.genAttrs [
|
||||
"aarch64-linux"
|
||||
"x86_64-linux"
|
||||
"x86_64-darwin"
|
||||
"aarch64-linux"
|
||||
"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 {
|
||||
formatter = forAllSystems (
|
||||
system: let
|
||||
|
@ -25,6 +42,9 @@
|
|||
declarative-jellyfin = import ./modules;
|
||||
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.lib.extend (
|
||||
final: prev: {
|
||||
toXMLGeneric = let
|
||||
{ nixpkgs, ... }:
|
||||
{
|
||||
toXMLGeneric =
|
||||
let
|
||||
toXMLRecursive =
|
||||
toXmlRecursive'
|
||||
"<?xml version='1.0' encoding='utf-8'?>\n"
|
||||
0;
|
||||
"<?xml version='1.0' encoding='utf-8'?>\n"
|
||||
0;
|
||||
|
||||
indent = depth: (
|
||||
if (depth <= 0)
|
||||
|
@ -13,33 +13,33 @@ nixpkgs.lib.extend (
|
|||
else (" " + (indent (depth - 1)))
|
||||
);
|
||||
|
||||
toXmlRecursive' = str: depth: xml: let
|
||||
# depth = if (builtins.isInt depth) then depth else (throw "DEPTH ISNT AN INT??? WTFFF");
|
||||
parseTag = str: depth: xml: (builtins.concatStringsSep "" [
|
||||
str
|
||||
"${indent depth}<${xml.name}${
|
||||
toXmlRecursive' = str: depth: xml:
|
||||
let
|
||||
parseTag = str: depth: xml: (builtins.concatStringsSep "" [
|
||||
str
|
||||
"${indent depth}<${xml.name}${
|
||||
if (builtins.hasAttr "content" xml)
|
||||
then ">"
|
||||
else " "
|
||||
}"
|
||||
|
||||
(
|
||||
if (builtins.hasAttr "properties" xml)
|
||||
then
|
||||
(" "
|
||||
+ builtins.concatStringsSep " " (nixpkgs.lib.attrsets.mapAttrsToList
|
||||
(
|
||||
if (builtins.hasAttr "properties" xml)
|
||||
then
|
||||
(" "
|
||||
+ builtins.concatStringsSep " " (nixpkgs.lib.attrsets.mapAttrsToList
|
||||
(name: value: "${name}=\"${nixpkgs.lib.strings.escapeXML value}\"")
|
||||
xml.properties))
|
||||
else ""
|
||||
)
|
||||
else ""
|
||||
)
|
||||
|
||||
(
|
||||
if builtins.hasAttr "content" xml
|
||||
then ((toXmlRecursive' "\n" (depth + 1) xml.content) + "</${xml.name}>")
|
||||
else "/>"
|
||||
)
|
||||
]);
|
||||
in
|
||||
(
|
||||
if builtins.hasAttr "content" xml
|
||||
then ((toXmlRecursive' "\n" (depth + 1) xml.content) + "</${xml.name}>")
|
||||
else "/>"
|
||||
)
|
||||
]);
|
||||
in
|
||||
if (builtins.isAttrs xml)
|
||||
then "${parseTag str depth xml}\n${indent (depth - 1)}"
|
||||
else if (builtins.isList xml)
|
||||
|
@ -50,6 +50,6 @@ nixpkgs.lib.extend (
|
|||
then xml
|
||||
else throw "Cannot convert a ${builtins.typeOf xml} to XML";
|
||||
in
|
||||
toXMLRecursive;
|
||||
}
|
||||
)
|
||||
toXMLRecursive;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
{...}: {
|
||||
imports = [./.];
|
||||
imports = [
|
||||
./config.nix
|
||||
./options
|
||||
];
|
||||
}
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
nixpkgs,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
cfg = config.services.declarative-jellyfin;
|
||||
toXml = (import ../../lib {inherit nixpkgs;}).toXMLGeneric;
|
||||
in
|
||||
with lib; {
|
||||
imports = [
|
||||
|
@ -36,7 +38,7 @@ in
|
|||
else (listOfStrPrepass value)
|
||||
)
|
||||
xml));
|
||||
toXml = name: x: (toXMLGeneric {
|
||||
toXml = name: x: (toXml {
|
||||
inherit name;
|
||||
properties = {
|
||||
"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