-
Notifications
You must be signed in to change notification settings - Fork 0
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
6ed2566
commit ed38958
Showing
3 changed files
with
85 additions
and
18 deletions.
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,78 @@ | ||
/* | ||
Copyright © 2023 Dimitris Dalianis <[email protected]> | ||
This file is part of CLI application keyvalDetector | ||
*/ | ||
package cmd | ||
|
||
import "testing" | ||
|
||
func TestIsSystemConfigMap(t *testing.T) { | ||
testCases := []struct { | ||
name string | ||
element string | ||
expected bool | ||
}{ | ||
{ | ||
name: "Empty string", | ||
element: "", | ||
expected: false, | ||
}, | ||
{ | ||
name: "Non system configmap", | ||
element: "my-configmap", | ||
expected: false, | ||
}, | ||
{ | ||
name: "System configmap", | ||
element: "cluster-info", | ||
expected: true, | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
t.Run(tc.name, func(t *testing.T) { | ||
result := isSystemConfigMap(tc.element) | ||
if result != tc.expected { | ||
t.Errorf("Expected %v, but got %v", tc.expected, result) | ||
} | ||
}) | ||
} | ||
|
||
} | ||
|
||
func TestContains(t *testing.T) { | ||
testCases := []struct { | ||
name string | ||
input []string | ||
element string | ||
expected bool | ||
}{ | ||
{ | ||
name: "Empty slice", | ||
input: []string{}, | ||
element: "abc", | ||
expected: false, | ||
}, | ||
{ | ||
name: "Element present in slice", | ||
input: []string{"abc", "def", "ghi"}, | ||
element: "def", | ||
expected: true, | ||
}, | ||
{ | ||
name: "Element not present in slice", | ||
input: []string{"abc", "def", "ghi"}, | ||
element: "xyz", | ||
expected: false, | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
t.Run(tc.name, func(t *testing.T) { | ||
result := contains(tc.input, tc.element) | ||
if result != tc.expected { | ||
t.Errorf("Expected %v, but got %v", tc.expected, result) | ||
} | ||
}) | ||
} | ||
} |
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