-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8552f8b
commit 3dfea62
Showing
2 changed files
with
36 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package system | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
) | ||
|
||
func Test_GetNamespace(t *testing.T) { | ||
testcases := []struct { | ||
envVar string | ||
expectEnvVar string | ||
}{ | ||
{ | ||
envVar: "", | ||
expectEnvVar: DefaultNamespace, | ||
}, | ||
{ | ||
envVar: "test", | ||
expectEnvVar: "test", | ||
}, | ||
} | ||
|
||
value := os.Getenv(SystemNamespaceEnvVar) | ||
defer func() { os.Setenv(SystemNamespaceEnvVar, value) }() | ||
|
||
for _, ts := range testcases { | ||
if err := os.Setenv(SystemNamespaceEnvVar, ts.envVar); err != nil { | ||
t.Fatalf("Failed to set ENV: %v", err) | ||
} | ||
|
||
if got, want := GetNamespace(), ts.expectEnvVar; got != want { | ||
t.Fatalf("Invalid namespace: got: %v, want: %v", got, want) | ||
} | ||
} | ||
} |