feat(test,k8s): add crd tests

This commit is contained in:
Jaka Hudoklin 2019-02-13 17:05:18 +01:00
parent bd6741fab1
commit fde2d5557c
No known key found for this signature in database
GPG key ID: 6A08896BFD32BD95
4 changed files with 79 additions and 1 deletions

View file

@ -16,6 +16,8 @@ with lib;
testing.tests = [
./k8s/simple.nix
./k8s/deployment.nix
./k8s/crd.nix
./k8s/1.13/crd.nix
./submodules/simple.nix
];
}

40
test/k8s/1.13/crd.nix Normal file
View file

@ -0,0 +1,40 @@
{ config, lib, kubenix, ... }:
with lib;
let
cfg = config.kubernetes.api.customresourcedefinitions.crontabs;
in {
imports = [
kubenix.k8s
];
test = {
name = "k8s/1.13/crd";
description = "Simple test tesing CRD for k8s 1.13";
enable = builtins.compareVersions config.kubernetes.version "1.13" >= 0;
assertions = [{
message = "should have versions set";
assertion = (head cfg.spec.versions).name == "v1";
}];
};
kubernetes.api.customresourcedefinitions.crontabs = {
metadata.name = "crontabs.stable.example.com";
spec = {
group = "stable.example.com";
versions = [{
name = "v1";
served = true;
storage = true;
}];
scope = "Namespaced";
names = {
plural = "crontabs";
singular = "crontab";
kind = "CronTab";
shortNames = ["ct"];
};
};
};
}

35
test/k8s/crd.nix Normal file
View file

@ -0,0 +1,35 @@
{ config, lib, kubenix, ... }:
with lib;
let
cfg = config.kubernetes.api.customresourcedefinitions.crontabs;
in {
imports = [
kubenix.k8s
];
test = {
name = "k8s/crd";
description = "Simple test tesing CRD";
assertions = [{
message = "should have group set";
assertion = cfg.spec.group == "stable.example.com";
}];
};
kubernetes.api.customresourcedefinitions.crontabs = {
metadata.name = "crontabs.stable.example.com";
spec = {
group = "stable.example.com";
version = "v1";
scope = "Namespaced";
names = {
plural = "crontabs";
singular = "crontab";
kind = "CronTab";
shortNames = ["ct"];
};
};
};
}