forked from anomalyco/opencode-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient_options_test.go
More file actions
81 lines (72 loc) · 1.8 KB
/
client_options_test.go
File metadata and controls
81 lines (72 loc) · 1.8 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
package opencode_test
import (
"testing"
"time"
"github.com/dominicnunez/opencode-sdk-go"
)
func TestWithTimeout_BoundaryValues(t *testing.T) {
tests := []struct {
name string
d time.Duration
wantErr bool
}{
{"negative", -1 * time.Second, true},
{"zero", 0, true},
{"positive", 1 * time.Second, false},
{"one_nanosecond", 1 * time.Nanosecond, false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
_, err := opencode.NewClient(opencode.WithTimeout(tt.d))
if (err != nil) != tt.wantErr {
t.Errorf("WithTimeout(%v): err=%v, wantErr=%v", tt.d, err, tt.wantErr)
}
})
}
}
func TestWithHTTPClient_Nil(t *testing.T) {
_, err := opencode.NewClient(opencode.WithHTTPClient(nil))
if err == nil {
t.Fatal("WithHTTPClient(nil): expected error, got nil")
}
}
func TestWithMaxRetries_BoundaryValues(t *testing.T) {
tests := []struct {
name string
n int
wantErr bool
}{
{"negative", -1, true},
{"zero", 0, false},
{"max_allowed", 10, false},
{"exceeds_cap", 11, true},
{"positive", 3, false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
_, err := opencode.NewClient(opencode.WithMaxRetries(tt.n))
if (err != nil) != tt.wantErr {
t.Errorf("WithMaxRetries(%d): err=%v, wantErr=%v", tt.n, err, tt.wantErr)
}
})
}
}
func TestWithMaxSuccessBodySize_BoundaryValues(t *testing.T) {
tests := []struct {
name string
n int64
wantErr bool
}{
{"negative", -1, true},
{"zero_unlimited", 0, false},
{"positive", 1024, false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
_, err := opencode.NewClient(opencode.WithMaxSuccessBodySize(tt.n))
if (err != nil) != tt.wantErr {
t.Errorf("WithMaxSuccessBodySize(%d): err=%v, wantErr=%v", tt.n, err, tt.wantErr)
}
})
}
}