-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfiguration_test.go
More file actions
67 lines (55 loc) · 1.75 KB
/
Copy pathconfiguration_test.go
File metadata and controls
67 lines (55 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package didww
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestEnvironmentSandboxURL(t *testing.T) {
assert.Equal(t, Environment("https://sandbox-api.didww.com/v3"), Sandbox)
}
func TestEnvironmentProductionURL(t *testing.T) {
assert.Equal(t, Environment("https://api.didww.com/v3"), Production)
}
func TestNewClientRequiresAPIKey(t *testing.T) {
_, err := NewClient("")
require.Error(t, err)
}
func TestNewClientWithValidAPIKey(t *testing.T) {
client, err := NewClient("test-api-key")
require.NoError(t, err)
require.NotNil(t, client)
}
func TestNewClientDefaultsToSandbox(t *testing.T) {
client, err := NewClient("test-api-key")
require.NoError(t, err)
assert.Equal(t, string(Sandbox), client.BaseURL())
}
func TestNewClientWithProductionEnvironment(t *testing.T) {
client, err := NewClient("test-api-key", WithEnvironment(Production))
require.NoError(t, err)
assert.Equal(t, string(Production), client.BaseURL())
}
func TestNewClientWithCustomBaseURL(t *testing.T) {
customURL := "http://localhost:3000/v3"
client, err := NewClient("test-api-key", WithBaseURL(customURL))
require.NoError(t, err)
assert.Equal(t, customURL, client.BaseURL())
}
func TestNewClientWithTimeout(t *testing.T) {
client, err := NewClient("test-api-key", WithTimeout(5000))
require.NoError(t, err)
require.NotNil(t, client)
}
func TestNewClientWithMultipleOptions(t *testing.T) {
client, err := NewClient("test-api-key",
WithEnvironment(Production),
WithTimeout(10000),
)
require.NoError(t, err)
assert.Equal(t, string(Production), client.BaseURL())
}
func TestClientAPIKey(t *testing.T) {
client, err := NewClient("my-secret-key")
require.NoError(t, err)
assert.Equal(t, "my-secret-key", client.APIKey())
}