-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ignore restart on a given rollout or deployment (#20)
* Pass 1 : parameter ignore metadata Signed-off-by: Viraj Kulkarni <[email protected]> * Pass 2 : Updated name Signed-off-by: Viraj Kulkarni <[email protected]> * Pass 2 : Add additional test for code coverage Signed-off-by: Viraj Kulkarni <[email protected]> --------- Signed-off-by: Viraj Kulkarni <[email protected]> Co-authored-by: Viraj Kulkarni <[email protected]>
- Loading branch information
Showing
4 changed files
with
66 additions
and
0 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
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,55 @@ | ||
package utils | ||
|
||
import ( | ||
"github.com/keikoproj/flippy/pkg/common" | ||
"github.com/tj/assert" | ||
"testing" | ||
) | ||
|
||
func TestIsStringMapSubset(t *testing.T) { | ||
|
||
masterMap := make(map[string]string) | ||
masterMap["test1"] = "test" | ||
masterMap["test2"] = "" | ||
masterMap["test3"] = "true" | ||
masterMap["test4"] = "false" | ||
|
||
subsetMap := make(map[string]string) | ||
subsetMap["test1"] = "test" | ||
|
||
tests := []struct { | ||
name string | ||
args string | ||
want bool | ||
}{ | ||
{"No addition to label", "empty", true}, | ||
{"Addition to label to ignore flippy with empty value", "test2", true}, | ||
{"Addition to label to ignore flippy", "test3", false}, | ||
{"Addition to label to ignore flippy with default value", "test4", true}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
if tt.args != "empty" { | ||
common.IgnoreMetadataKey = tt.args | ||
} | ||
if got := IsStringMapSubset(masterMap, subsetMap); got != tt.want { | ||
t.Errorf("IsStringMapSubset() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} | ||
|
||
func TestIsStringMapSubsetNegative(t *testing.T) { | ||
|
||
masterMap := make(map[string]string) | ||
masterMap["test1"] = "test" | ||
masterMap["test2"] = "" | ||
masterMap["test3"] = "true" | ||
masterMap["test4"] = "false" | ||
|
||
subsetMap := make(map[string]string) | ||
subsetMap["test5"] = "test" | ||
|
||
got := IsStringMapSubset(masterMap, subsetMap) | ||
assert.Equal(t, false, got) | ||
} |