diff --git a/pkgs/applications/networking/cluster/helm/plugins/helm-unittest.nix b/pkgs/applications/networking/cluster/helm/plugins/helm-unittest.nix index 983890fbc3c0..08d653227f02 100644 --- a/pkgs/applications/networking/cluster/helm/plugins/helm-unittest.nix +++ b/pkgs/applications/networking/cluster/helm/plugins/helm-unittest.nix @@ -1,14 +1,18 @@ { buildGoModule, fetchFromGitHub, + kubernetes-helm, lib, nix-update-script, + runCommand, + wrapHelm, + writableTmpDirAsHomeHook, }: let version = "1.1.1"; in -buildGoModule { +buildGoModule (finalAttrs: { pname = "helm-unittest"; inherit version; @@ -46,6 +50,26 @@ buildGoModule { ''; passthru = { + tests.smoke = + let + helm = wrapHelm kubernetes-helm { + plugins = [ finalAttrs.finalPackage ]; + }; + in + runCommand "helm-unittest-plugin-smoke" + { + nativeBuildInputs = [ + helm + writableTmpDirAsHomeHook + ]; + } + '' + cp -r ${./tests/helm-unittest/smoke} chart + chmod -R u+w chart + helm unittest chart + touch $out + ''; + updateScript = nix-update-script { }; }; @@ -58,4 +82,4 @@ buildGoModule { yurrriq ]; }; -} +}) diff --git a/pkgs/applications/networking/cluster/helm/plugins/tests/helm-unittest/smoke/Chart.yaml b/pkgs/applications/networking/cluster/helm/plugins/tests/helm-unittest/smoke/Chart.yaml new file mode 100644 index 000000000000..fe0d4f805044 --- /dev/null +++ b/pkgs/applications/networking/cluster/helm/plugins/tests/helm-unittest/smoke/Chart.yaml @@ -0,0 +1,3 @@ +apiVersion: v2 +name: smoke +version: 0.1.0 diff --git a/pkgs/applications/networking/cluster/helm/plugins/tests/helm-unittest/smoke/templates/configmap.yaml b/pkgs/applications/networking/cluster/helm/plugins/tests/helm-unittest/smoke/templates/configmap.yaml new file mode 100644 index 000000000000..25dff3db6797 --- /dev/null +++ b/pkgs/applications/networking/cluster/helm/plugins/tests/helm-unittest/smoke/templates/configmap.yaml @@ -0,0 +1,6 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: "{{ .Release.Name }}-smoke" +data: + value: "{{ .Values.value }}" diff --git a/pkgs/applications/networking/cluster/helm/plugins/tests/helm-unittest/smoke/tests/configmap_test.yaml b/pkgs/applications/networking/cluster/helm/plugins/tests/helm-unittest/smoke/tests/configmap_test.yaml new file mode 100644 index 000000000000..ce6b1ac74dec --- /dev/null +++ b/pkgs/applications/networking/cluster/helm/plugins/tests/helm-unittest/smoke/tests/configmap_test.yaml @@ -0,0 +1,11 @@ +suite: configmap +templates: + - templates/configmap.yaml +tests: + - it: renders the configured value + set: + value: ok + asserts: + - equal: + path: data.value + value: ok