From 0d3289eb0b2db911d1b08d54833b4ddf127f6d25 Mon Sep 17 00:00:00 2001 From: yxxhero Date: Fri, 8 Oct 2021 23:02:29 +0800 Subject: [PATCH] add unittest for SetNamespace method Signed-off-by: yxxhero --- pkg/cli/environment_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pkg/cli/environment_test.go b/pkg/cli/environment_test.go index 31ba7a237..1c3dc815e 100644 --- a/pkg/cli/environment_test.go +++ b/pkg/cli/environment_test.go @@ -25,6 +25,20 @@ import ( "github.com/spf13/pflag" ) +func TestSetNamespace(t *testing.T) { + settings := New() + + if settings.namespace != "" { + t.Errorf("Expected empty namespace, got %s", settings.namespace) + } + + settings.SetNamespace("testns") + if settings.namespace != "testns" { + t.Errorf("Expected namespace testns, got %s", settings.namespace) + } + +} + func TestEnvSettings(t *testing.T) { tests := []struct { name string