-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathecho_test.go
52 lines (43 loc) · 867 Bytes
/
echo_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
package lifxlan_test
import (
"context"
"testing"
"time"
"go.yhsif.com/lifxlan/mock"
)
func TestEcho(t *testing.T) {
if testing.Short() {
t.Skip("skipping test in short mode.")
}
const timeout = time.Millisecond * 200
_, device := mock.StartService(t)
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
t.Run(
"UserPayload",
func(t *testing.T) {
err := device.Echo(ctx, nil, []byte("payload"))
if err != nil {
t.Fatal(err)
}
},
)
t.Run(
"OversizePayload",
func(t *testing.T) {
err := device.Echo(ctx, nil, []byte("this is a big string that's longer than the allowed 64 bytes for the echo payload"))
if err != nil {
t.Fatal(err)
}
},
)
t.Run(
"DefaultPayload",
func(t *testing.T) {
err := device.Echo(ctx, nil, nil)
if err != nil {
t.Fatal(err)
}
},
)
}