mirror of
https://github.com/TECHNOFAB11/kubenix.git
synced 2025-12-12 16:10:05 +01:00
feat: initial testing support
This commit is contained in:
parent
e286c9b0e8
commit
9f8ca8447e
6 changed files with 362 additions and 127 deletions
34
test/k8s/deployment.nix
Normal file
34
test/k8s/deployment.nix
Normal 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
23
test/k8s/simple.nix
Normal 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 = {};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue