forked from ethereum/hive
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtestload_test.go
More file actions
48 lines (44 loc) · 926 Bytes
/
testload_test.go
File metadata and controls
48 lines (44 loc) · 926 Bytes
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
package main
import (
"reflect"
"strings"
"testing"
)
func TestLoad(t *testing.T) {
data := `// this is a test comment
// this is the second line
// speconly: lalalala
>> {"type":"send"}
<< {"type":"recv"}
`
expectedComment := `this is a test comment
this is the second line
speconly: lalalala
`
expectedMessages := []rpcTestMessage{
{
data: `{"type":"send"}`,
send: true,
},
{
data: `{"type":"recv"}`,
send: false,
},
}
result, err := loadTestFile("the-test", strings.NewReader(data))
if err != nil {
t.Fatal("error:", err)
}
if result.name != "the-test" {
t.Error("wrong test name:", result.comment)
}
if result.comment != expectedComment {
t.Errorf("wrong test comment %q", result.comment)
}
if !result.speconly {
t.Error("test is not marked speconly")
}
if !reflect.DeepEqual(result.messages, expectedMessages) {
t.Errorf("wrong test messages %+v", result.messages)
}
}