forked from k1LoW/runn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
loadt_test.go
68 lines (63 loc) · 1.27 KB
/
loadt_test.go
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
//go:build loadt
package runn
import (
"context"
"testing"
"time"
"github.com/ryo-yamaoka/otchkiss"
"github.com/ryo-yamaoka/otchkiss/setting"
)
func TestLoadt(t *testing.T) {
tests := []struct {
in string
concarent int
}{
{"testdata/book/include_main.yml", 2},
}
for _, tt := range tests {
t.Run(tt.in, func(t *testing.T) {
t.Parallel()
opts := []Option{}
o, err := Load(tt.in, opts...)
if err != nil {
t.Error(err)
}
s, err := setting.New(tt.concarent, 0, 5*time.Second, 5*time.Second)
if err != nil {
t.Error(err)
}
ot, err := otchkiss.FromConfig(o, s, 100_000_000)
if err != nil {
t.Error(err)
}
if err := ot.Start(context.Background()); err != nil {
t.Error(err)
}
})
}
}
func TestCheckThreshold(t *testing.T) {
tests := []struct {
lr *loadtResult
threshold string
wantErr bool
}{
{&loadtResult{}, "", false},
{&loadtResult{succeeded: 11}, "succeeded > 10", false},
{&loadtResult{failed: 10}, "failed < 10", true},
}
for _, tt := range tests {
t.Run(tt.threshold, func(t *testing.T) {
err := tt.lr.CheckThreshold(tt.threshold)
if err != nil {
if tt.wantErr {
return
}
t.Errorf("got err: %s", err)
}
if tt.wantErr {
t.Error("want error")
}
})
}
}