Skip to content

Commit

Permalink
Add unit tests for FIQL name filter function
Browse files Browse the repository at this point in the history
  • Loading branch information
thunderboltsid committed Oct 2, 2024
1 parent 0a9b12b commit cfbda29
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions controllers/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,3 +229,39 @@ func TestGetPrismCentralClientForCluster(t *testing.T) {
assert.NoError(t, err)
})
}

func TestGetFilterForName(t *testing.T) {
tt := []struct {
name string
expected string
testName string
}{
{
name: "test-name",
expected: "name==test-name",
testName: "ReturnsCorrectFilterForValidName",
},
{
name: "test name with spaces",
expected: "name==test+name+with+spaces",
testName: "ReturnsCorrectFilterForNameWithSpecialCharacters",
},
{
name: "",
expected: "name==",
testName: "ReturnsCorrectFilterForEmptyName",
},
{
name: "test|name=with?special#characters",
expected: "name==test%7Cname%3Dwith%3Fspecial%23characters",
testName: "ReturnsCorrectFilterForNameWithURLCharacters",
},
}

for _, tc := range tt {
t.Run(tc.testName, func(t *testing.T) {
filter := getFilterForName(tc.name)
assert.Equal(t, tc.expected, filter)
})
}
}

0 comments on commit cfbda29

Please sign in to comment.