Skip to content

Commit

Permalink
chore: Add test for NormalizedURl and fix existing tests
Browse files Browse the repository at this point in the history
Signed-off-by: Karanjot Singh <[email protected]>
  • Loading branch information
0xquark committed Jun 6, 2024
1 parent fbe9a7d commit 7040f52
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions atlan/assets/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ func TestEnvConfig(t *testing.T) {

// Assert API key and base URL are correctly set
assert.Equal(t, "your_api_key", DefaultAtlanClient.ApiKey)
assert.Equal(t, "your_base_url", DefaultAtlanClient.host)
assert.Equal(t, "https://your_base_url", DefaultAtlanClient.host)
}

func TestEnvConfigUsingContext(t *testing.T) {
// Set up environment variables
apiKey := "your_api_key"
baseURL := "your_base_url"
baseURL := "https://your_base_url"

// Initialize client
ctx, err := Context(baseURL, apiKey)
Expand All @@ -50,6 +50,33 @@ func TestEnvConfigUsingContext(t *testing.T) {
assert.Equal(t, baseURL, ctx.host)
}

func TestContextWithNormalizedURL(t *testing.T) {
tests := []struct {
input string
expected string
}{
{"devx9.atlan.com", "https://devx9.atlan.com"},
{"https://devx9.atlan.com", "https://devx9.atlan.com"},
{"devx9.atlan.com/some/path", "https://devx9.atlan.com"},
{"devx9.atlan.com?query=param", "https://devx9.atlan.com"},
{"https://devx9.atlan.com/some/path", "https://devx9.atlan.com"},
}

apiKey := "your_api_key"

for _, test := range tests {
t.Run(test.input, func(t *testing.T) {
// Initialize client context with the test input
ctx, err := Context(test.input, apiKey)

assert.NoError(t, err)

// Ensure the base URL is normalized correctly
assert.Equal(t, test.expected, ctx.host)
})
}
}

func TestLoggerConfig(t *testing.T) {
ctx, _ := Context("api_key", "baseurl")

Expand Down

0 comments on commit 7040f52

Please sign in to comment.