Skip to content

Commit

Permalink
Adding unittests
Browse files Browse the repository at this point in the history
Signed-off-by: David Wertenteil <dwertent@armosec.io>
  • Loading branch information
dwertent committed Apr 1, 2024
1 parent f2fc733 commit 1e61041
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions pkg/client/v1/kscloudapi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,3 +402,39 @@ func withAPIGarbled(enabled bool) mockAPIOption {
o.withGarbled = enabled
}
}

func TestGetExceptionsURL(t *testing.T) {
ks, err := NewKSCloudAPI("https://api.kubescape.com", "https://api.google.com/report", "00000000-0000-0000-0000-000000000000", "00000000-0000-0000-0000-000000000000")
if err != nil {
t.Fatal(err)
}

tests := []struct {
name string
clusterName string
expectedURL string
}{
{
name: "should return correct URL with given cluster name",
clusterName: "testCluster",
expectedURL: "https://api.kubescape.com/api/v1/controlExceptions?customerGUID=00000000-0000-0000-0000-000000000000&gitRegoStoreVersion=v2",
},
{
name: "should return correct URL with different cluster name",
clusterName: "anotherTestCluster",
expectedURL: "https://api.kubescape.com/api/v1/controlExceptions?customerGUID=00000000-0000-0000-0000-000000000000&gitRegoStoreVersion=v2",
},
{
name: "should return correct URL when cluster name is empty",
clusterName: "",
expectedURL: "https://api.kubescape.com/api/v1/controlExceptions?customerGUID=00000000-0000-0000-0000-000000000000&gitRegoStoreVersion=v2",
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
resultURL := ks.getExceptionsURL(tt.clusterName)
require.Equal(t, tt.expectedURL, resultURL)
})
}
}

0 comments on commit 1e61041

Please sign in to comment.