Skip to content

Commit 72f630a

Browse files
authored
Merge pull request #44 from makasim/make-watch-test-cases-extension-friendly
make watch test cases extension friendly
2 parents fb67b94 + d67728a commit 72f630a

File tree

5 files changed

+52
-107
lines changed

5 files changed

+52
-107
lines changed

testcases/watch_labels.go

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -55,33 +55,18 @@ func WatchLabels(t TestingT, d flowstate.Doer, _ FlowRegistry) {
5555
require.NoError(t, err)
5656
defer lis.Close()
5757

58-
require.Equal(t, []flowstate.State{
59-
{
60-
ID: "aTID",
61-
Rev: 1,
62-
Transition: flowstate.Transition{
63-
Annotations: map[string]string{
64-
`flowstate.state`: `paused`,
65-
},
66-
},
67-
Labels: map[string]string{
68-
`foo`: `fooVal`,
69-
},
70-
},
71-
{
72-
ID: "aTID",
73-
Rev: 2,
74-
Transition: flowstate.Transition{
75-
Annotations: map[string]string{
76-
`flowstate.state`: `paused`,
77-
},
78-
},
79-
Labels: map[string]string{
80-
`foo`: `fooVal`,
81-
`bar`: `barVal`,
82-
},
83-
},
84-
}, watchCollectStates(t, lis, 2))
58+
actStates := watchCollectStates(t, lis, 2)
59+
60+
require.Equal(t, flowstate.StateID(`aTID`), actStates[0].ID)
61+
require.Equal(t, int64(1), actStates[0].Rev)
62+
require.Equal(t, `paused`, actStates[0].Transition.Annotations[`flowstate.state`])
63+
require.Equal(t, `fooVal`, actStates[0].Labels[`foo`])
64+
65+
require.Equal(t, flowstate.StateID(`aTID`), actStates[1].ID)
66+
require.Equal(t, int64(2), actStates[1].Rev)
67+
require.Equal(t, `paused`, actStates[1].Transition.Annotations[`flowstate.state`])
68+
require.Equal(t, `fooVal`, actStates[1].Labels[`foo`])
69+
require.Equal(t, `barVal`, actStates[1].Labels[`bar`])
8570
}
8671

8772
func watchCollectStates(t TestingT, lis flowstate.WatchListener, limit int) []flowstate.State {

testcases/watch_or_labels.go

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -50,30 +50,18 @@ func WatchORLabels(t TestingT, d flowstate.Doer, _ FlowRegistry) {
5050
require.NoError(t, err)
5151
defer lis.Close()
5252

53-
require.Equal(t, []flowstate.State{
54-
{
55-
ID: "aTID",
56-
Rev: 1,
57-
Transition: flowstate.Transition{
58-
Annotations: map[string]string{
59-
`flowstate.state`: `paused`,
60-
},
61-
},
62-
Labels: map[string]string{
63-
`foo`: `fooVal`,
64-
},
65-
},
66-
{
67-
ID: "anotherTID",
68-
Rev: 2,
69-
Transition: flowstate.Transition{
70-
Annotations: map[string]string{
71-
`flowstate.state`: `paused`,
72-
},
73-
},
74-
Labels: map[string]string{
75-
`bar`: `barVal`,
76-
},
77-
},
78-
}, watchCollectStates(t, lis, 2))
53+
actStates := watchCollectStates(t, lis, 2)
54+
55+
require.Len(t, actStates, 2)
56+
require.Equal(t, flowstate.StateID(`aTID`), actStates[0].ID)
57+
require.Equal(t, int64(1), actStates[0].Rev)
58+
require.Equal(t, `paused`, actStates[0].Transition.Annotations[`flowstate.state`])
59+
require.Equal(t, `fooVal`, actStates[0].Labels[`foo`])
60+
require.Equal(t, ``, actStates[0].Labels[`bar`])
61+
62+
require.Equal(t, flowstate.StateID(`anotherTID`), actStates[1].ID)
63+
require.Equal(t, int64(2), actStates[1].Rev)
64+
require.Equal(t, `paused`, actStates[1].Transition.Annotations[`flowstate.state`])
65+
require.Equal(t, ``, actStates[1].Labels[`foo`])
66+
require.Equal(t, `barVal`, actStates[1].Labels[`bar`])
7967
}

testcases/watch_since_latest.go

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,11 @@ func WatchSinceLatest(t TestingT, d flowstate.Doer, _ FlowRegistry) {
4444
require.NoError(t, err)
4545
defer lis.Close()
4646

47-
require.Equal(t, []flowstate.State{
48-
{
49-
ID: "aTID",
50-
Rev: 3,
51-
Transition: flowstate.Transition{
52-
Annotations: map[string]string{
53-
`flowstate.state`: `paused`,
54-
},
55-
},
56-
Labels: map[string]string{
57-
`foo`: `fooVal`,
58-
},
59-
},
60-
}, watchCollectStates(t, lis, 1))
47+
actStates := watchCollectStates(t, lis, 1)
48+
49+
require.Len(t, actStates, 1)
50+
require.Equal(t, flowstate.StateID(`aTID`), actStates[0].ID)
51+
require.Equal(t, int64(3), actStates[0].Rev)
52+
require.Equal(t, `paused`, actStates[0].Transition.Annotations[`flowstate.state`])
53+
require.Equal(t, `fooVal`, actStates[0].Labels[`foo`])
6154
}

testcases/watch_since_rev.go

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -45,30 +45,16 @@ func WatchSinceRev(t TestingT, d flowstate.Doer, _ FlowRegistry) {
4545
require.NoError(t, err)
4646
defer lis.Close()
4747

48-
require.Equal(t, []flowstate.State{
49-
{
50-
ID: "aTID",
51-
Rev: 2,
52-
Transition: flowstate.Transition{
53-
Annotations: map[string]string{
54-
`flowstate.state`: `paused`,
55-
},
56-
},
57-
Labels: map[string]string{
58-
`foo`: `fooVal`,
59-
},
60-
},
61-
{
62-
ID: "aTID",
63-
Rev: 3,
64-
Transition: flowstate.Transition{
65-
Annotations: map[string]string{
66-
`flowstate.state`: `paused`,
67-
},
68-
},
69-
Labels: map[string]string{
70-
`foo`: `fooVal`,
71-
},
72-
},
73-
}, watchCollectStates(t, lis, 2))
48+
actStates := watchCollectStates(t, lis, 2)
49+
50+
require.Len(t, actStates, 2)
51+
require.Equal(t, flowstate.StateID(`aTID`), actStates[0].ID)
52+
require.Equal(t, int64(2), actStates[0].Rev)
53+
require.Equal(t, `paused`, actStates[0].Transition.Annotations[`flowstate.state`])
54+
require.Equal(t, `fooVal`, actStates[0].Labels[`foo`])
55+
56+
require.Equal(t, flowstate.StateID(`aTID`), actStates[1].ID)
57+
require.Equal(t, int64(3), actStates[1].Rev)
58+
require.Equal(t, `paused`, actStates[1].Transition.Annotations[`flowstate.state`])
59+
require.Equal(t, `fooVal`, actStates[1].Labels[`foo`])
7460
}

testcases/watch_since_time.go

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,11 @@ func WatchSinceTime(t TestingT, d flowstate.Doer, _ FlowRegistry) {
4747
require.NoError(t, err)
4848
defer lis2.Close()
4949

50-
require.Equal(t, []flowstate.State{
51-
{
52-
ID: "aTID",
53-
Rev: 1,
54-
Transition: flowstate.Transition{
55-
Annotations: map[string]string{
56-
`flowstate.state`: `paused`,
57-
},
58-
},
59-
Labels: map[string]string{
60-
`foo`: `fooVal`,
61-
},
62-
},
63-
}, watchCollectStates(t, lis2, 1))
50+
actStates := watchCollectStates(t, lis2, 1)
51+
52+
require.Len(t, actStates, 1)
53+
require.Equal(t, flowstate.StateID(`aTID`), actStates[0].ID)
54+
require.Equal(t, int64(1), actStates[0].Rev)
55+
require.Equal(t, `paused`, actStates[0].Transition.Annotations[`flowstate.state`])
56+
require.Equal(t, `fooVal`, actStates[0].Labels[`foo`])
6457
}

0 commit comments

Comments
 (0)