From faef77d14306c467a0022feffaf2527bf110d7e6 Mon Sep 17 00:00:00 2001 From: yxxhero Date: Thu, 28 Apr 2022 09:01:02 +0800 Subject: [PATCH] add unittest for error.go in pkg/app Signed-off-by: yxxhero --- pkg/app/errors_test.go | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 pkg/app/errors_test.go diff --git a/pkg/app/errors_test.go b/pkg/app/errors_test.go new file mode 100644 index 00000000..b870f1c1 --- /dev/null +++ b/pkg/app/errors_test.go @@ -0,0 +1,39 @@ +package app + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +// TestNoMatchingHelmfileError tests the NoMatchingHelmfileError error +func TestNoMatchingHelmfileError_Error(t *testing.T) { + tests := []struct { + selectors []string + env string + expected string + }{ + { + selectors: []string{"a", "b"}, + env: "c", + expected: "err: no releases found that matches specified selector(a, b) and environment(c), in any helmfile", + }, + { + selectors: []string{"a", "b"}, + expected: "err: no releases found that matches specified selector(a, b) and environment(), in any helmfile", + }, + { + env: "c", + expected: "err: no releases found that matches specified selector() and environment(c), in any helmfile", + }, + } + + for _, test := range tests { + err := &NoMatchingHelmfileError{ + selectors: test.selectors, + env: test.env, + } + + require.Equal(t, test.expected, err.Error()) + } +}