feat: initial testing support

This commit is contained in:
Jaka Hudoklin 2019-02-12 16:22:18 +01:00
parent e286c9b0e8
commit 9f8ca8447e
No known key found for this signature in database
GPG key ID: 6A08896BFD32BD95
6 changed files with 362 additions and 127 deletions

34
test/k8s/deployment.nix Normal file
View file

@ -0,0 +1,34 @@
{ config, test, kubenix, ... }:
let
cfg = config.kubernetes.api.Deployment.nginx;
in {
imports = [
kubenix.k8s
];
test = {
name = "k8s/deployment/simple";
description = "Simple k8s testing a simple deployment";
assertions = [{
message = "should have correct apiVersion and kind set";
assertion = cfg.apiVersion == "apps/v1" && cfg.kind == "Deployment";
} {
message = "should have replicas set";
assertion = cfg.spec.replicas == 10;
}];
};
kubernetes.api.Deployment.nginx = {
spec = {
replicas = 10;
selector.matchLabels.app = "nginx";
template.metadata.labels.app = "nginx";
template.spec = {
containers.nginx = {
image = "nginx";
};
};
};
};
}

23
test/k8s/simple.nix Normal file
View file

@ -0,0 +1,23 @@
{ config, test, kubenix, ... }:
let
cfg = config.kubernetes.api.Pod.nginx;
in {
imports = [
kubenix.k8s
];
test = {
name = "k8s/simple";
description = "Simple k8s testing wheter name, apiVersion and kind are preset";
assertions = [{
message = "should have apiVersion and kind set";
assertion = cfg.apiVersion == "v1" && cfg.kind == "Pod";
} {
message = "should have name set";
assertion = cfg.metadata.name == "nginx";
}];
};
kubernetes.api.Pod.nginx = {};
}