-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_test.go
49 lines (45 loc) · 976 Bytes
/
main_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
package main
import (
"testing"
"time"
"github.com/tinywell/loadgen/lib"
"github.com/tinywell/loadgen/mock"
"github.com/tinywell/loadgen/model"
)
func TestAll(t *testing.T) {
caller := mock.NewMockCaller()
tickets, _ := lib.NewTickets(2)
set := lib.ParamSet{
Caller: caller,
Tickets: tickets,
Lps: 10,
TimeoutNS: time.Second * 2,
DurationNS: time.Second * 10,
ResultChan: make(chan *model.LDResult),
}
gen := lib.NewGenerator(set)
if ok := gen.Start(); ok {
t.Log("OK")
}
for res := range set.ResultChan {
t.Log(res)
}
}
func TestStop(t *testing.T) {
caller := mock.NewMockCaller()
tickets, _ := lib.NewTickets(2)
set := lib.ParamSet{
Caller: caller,
Tickets: tickets,
Lps: 10,
TimeoutNS: time.Second * 2,
DurationNS: time.Second * 10,
ResultChan: make(chan *model.LDResult),
}
gen := lib.NewGenerator(set)
if ok := gen.Start(); ok {
t.Log("OK")
}
time.Sleep(time.Second * 2)
gen.Stop()
}