-
-
Notifications
You must be signed in to change notification settings - Fork 34
/
kv_test.go
51 lines (48 loc) · 1.22 KB
/
kv_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
package runn
import (
"context"
"testing"
"time"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
)
func TestRunNWithKV(t *testing.T) {
ctx := context.Background()
book := "testdata/book/kv.yml"
want := newRunNResult(t, 1, []*RunResult{
{
ID: "6fdfa57431f3700a161b5ef02f945a117fd70216",
Path: "testdata/book/kv.yml",
Err: nil,
StepResults: []*StepResult{
{ID: "6fdfa57431f3700a161b5ef02f945a117fd70216?step=0", Key: "0", Err: nil},
{ID: "6fdfa57431f3700a161b5ef02f945a117fd70216?step=1", Key: "1", Err: nil},
{ID: "6fdfa57431f3700a161b5ef02f945a117fd70216?step=2", Key: "2", Err: nil},
},
},
})
ops, err := Load(book)
if err != nil {
t.Fatal(err)
}
go func() {
time.Sleep(50 * time.Millisecond)
ops.SetKV("email", "[email protected]")
ops.SetKV("map", map[string]any{
"str": "hello",
"int": 123,
})
ops.SetKV("dot.key", "dot.value")
}()
if err := ops.RunN(ctx); err != nil {
t.Error(err)
}
got := ops.Result()
opts := []cmp.Option{
cmpopts.IgnoreFields(runResultSimplified{}, "Elapsed"),
cmpopts.IgnoreFields(stepResultSimplified{}, "Elapsed"),
}
if diff := cmp.Diff(got.simplify(), want.simplify(), opts...); diff != "" {
t.Error(diff)
}
}