Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding unittests #25

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
})
}
}
Loading