From 909c6f0394a79b804866437fd898c83fcf8f6cf9 Mon Sep 17 00:00:00 2001 From: superherointj <5861043+superherointj@users.noreply.github.com> Date: Wed, 14 Jul 2021 07:53:00 -0300 Subject: [PATCH] tfk8s: add passthru.tests.sample1 --- pkgs/tools/misc/tfk8s/default.nix | 6 +++++- pkgs/tools/misc/tfk8s/tests/sample1/default.nix | 11 +++++++++++ pkgs/tools/misc/tfk8s/tests/sample1/input.yaml | 7 +++++++ pkgs/tools/misc/tfk8s/tests/sample1/output.tf | 12 ++++++++++++ 4 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 pkgs/tools/misc/tfk8s/tests/sample1/default.nix create mode 100644 pkgs/tools/misc/tfk8s/tests/sample1/input.yaml create mode 100644 pkgs/tools/misc/tfk8s/tests/sample1/output.tf diff --git a/pkgs/tools/misc/tfk8s/default.nix b/pkgs/tools/misc/tfk8s/default.nix index 536b8f1386d6..d9c9ad0451bb 100644 --- a/pkgs/tools/misc/tfk8s/default.nix +++ b/pkgs/tools/misc/tfk8s/default.nix @@ -1,4 +1,4 @@ -{ lib, buildGoModule, fetchFromGitHub }: +{ lib, buildGoModule, fetchFromGitHub, callPackage }: buildGoModule rec { pname = "tfk8s"; @@ -30,6 +30,10 @@ buildGoModule rec { $out/bin/tfk8s --version | grep ${tag} > /dev/null ''; + passthru.tests = { + sample1 = callPackage ./tests/sample1 { }; + }; + meta = with lib; { description = "An utility to convert Kubernetes YAML manifests to Terraform's HCL format"; license = licenses.mit; diff --git a/pkgs/tools/misc/tfk8s/tests/sample1/default.nix b/pkgs/tools/misc/tfk8s/tests/sample1/default.nix new file mode 100644 index 000000000000..6b06dbf32340 --- /dev/null +++ b/pkgs/tools/misc/tfk8s/tests/sample1/default.nix @@ -0,0 +1,11 @@ +{ runCommandCC, tfk8s }: + +runCommandCC "tfk8s-test-sample1" { + buildInputs = [ + tfk8s + ]; + meta.timeout = 60; + } + '' + cmp <(${tfk8s}/bin/tfk8s -f ${./input.yaml}) ${./output.tf} > $out + '' diff --git a/pkgs/tools/misc/tfk8s/tests/sample1/input.yaml b/pkgs/tools/misc/tfk8s/tests/sample1/input.yaml new file mode 100644 index 000000000000..58ed0eb11d76 --- /dev/null +++ b/pkgs/tools/misc/tfk8s/tests/sample1/input.yaml @@ -0,0 +1,7 @@ +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: test +data: + TEST: test diff --git a/pkgs/tools/misc/tfk8s/tests/sample1/output.tf b/pkgs/tools/misc/tfk8s/tests/sample1/output.tf new file mode 100644 index 000000000000..51d564400b55 --- /dev/null +++ b/pkgs/tools/misc/tfk8s/tests/sample1/output.tf @@ -0,0 +1,12 @@ +resource "kubernetes_manifest" "configmap_test" { + manifest = { + "apiVersion" = "v1" + "data" = { + "TEST" = "test" + } + "kind" = "ConfigMap" + "metadata" = { + "name" = "test" + } + } +}