Repository navigation
Expand file tree
/
Copy pathe2b_test.go
More file actions
82 lines (72 loc) · 1.89 KB
/
Copy pathe2b_test.go
File metadata and controls
82 lines (72 loc) · 1.89 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package e2b
import (
"os"
"testing"
)
func TestResolveAPIKey(t *testing.T) {
t.Run("explicit value", func(t *testing.T) {
got := resolveAPIKey("my-key")
if got != "my-key" {
t.Errorf("resolveAPIKey = %q, want %q", got, "my-key")
}
})
t.Run("from env", func(t *testing.T) {
t.Setenv(apiKeyEnv, "env-key")
got := resolveAPIKey("")
if got != "env-key" {
t.Errorf("resolveAPIKey = %q, want %q", got, "env-key")
}
})
t.Run("empty", func(t *testing.T) {
// Ensure the env var is unset for this subtest.
if _, ok := os.LookupEnv(apiKeyEnv); ok {
t.Setenv(apiKeyEnv, "")
}
got := resolveAPIKey("")
if got != "" {
t.Errorf("resolveAPIKey = %q, want %q", got, "")
}
})
}
func TestResolveAPIBaseURL(t *testing.T) {
t.Run("explicit value", func(t *testing.T) {
got := resolveAPIBaseURL("https://custom.api")
if got != "https://custom.api" {
t.Errorf("got %q, want %q", got, "https://custom.api")
}
})
t.Run("from env", func(t *testing.T) {
t.Setenv(apiURLEnv, "https://env.api")
got := resolveAPIBaseURL("")
if got != "https://env.api" {
t.Errorf("got %q, want %q", got, "https://env.api")
}
})
t.Run("default", func(t *testing.T) {
got := resolveAPIBaseURL("")
if got != DefaultAPIBaseURL {
t.Errorf("got %q, want %q", got, DefaultAPIBaseURL)
}
})
}
func TestResolveSandboxDomain(t *testing.T) {
t.Run("explicit value", func(t *testing.T) {
got := resolveSandboxDomain("custom.domain")
if got != "custom.domain" {
t.Errorf("got %q, want %q", got, "custom.domain")
}
})
t.Run("from env", func(t *testing.T) {
t.Setenv(sandboxURLEnv, "env.domain")
got := resolveSandboxDomain("")
if got != "env.domain" {
t.Errorf("got %q, want %q", got, "env.domain")
}
})
t.Run("default", func(t *testing.T) {
got := resolveSandboxDomain("")
if got != defaultSandboxDomain {
t.Errorf("got %q, want %q", got, defaultSandboxDomain)
}
})
}