Debian Codegraph @

matchers/via_polling_test.go

raw symbols SCIP
1 package matchers_testscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/
2
3 import (
4 "fmtscip-go gomod github.com/golang/go/src go1.21.4 fmt/"
5 "reflectscip-go gomod github.com/golang/go/src go1.21.4 reflect/"
6 "testingscip-go gomod github.com/golang/go/src go1.21.4 testing/"
7 "timescip-go gomod github.com/golang/go/src go1.21.4 time/"
8
9 "github.com/poy/onpar/matchersscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/"
10 )
11
12 func TestViaPollingFailsPolls100Timesscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/TestViaPollingFailsPolls100Times().(t *testingscip-go gomod github.com/golang/go/src go1.21.4 testing/.Tscip-go gomod github.com/golang/go/src go1.21.4 testing/T#) {
13 t.Parallelscip-go gomod github.com/golang/go/src go1.21.4 testing/T#Parallel().()
14 matcher := newMockMatcherscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/newMockMatcher().(t, timescip-go gomod github.com/golang/go/src go1.21.4 time/.Secondscip-go gomod github.com/golang/go/src go1.21.4 time/Second.)
15 m := matchersscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/.ViaPollingscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/ViaPolling().(matcher)
16
17 callCount := make(chan bool, 200)
18 f := func() int {
19 callCount <- true
20 matcher.MatchOutputscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/mockMatcher#MatchOutput..ResultValuescip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/mockMatcher#$anon_1ee3ff7fc72ebcca#ResultValue. <- nil
21 matcher.MatchOutputscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/mockMatcher#MatchOutput..Errscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/mockMatcher#$anon_1ee3ff7fc72ebcca#Err. <- fmtscip-go gomod github.com/golang/go/src go1.21.4 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.21.4 fmt/Errorf().("still wrong")
22 return 99
23 }
24 m.Matchscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/ViaPollingMatcher#Match().(f)
25
26 if len(callCount) != 100 {
27 t.Errorfscip-go gomod github.com/golang/go/src go1.21.4 testing/common#Errorf().("expected callCount (len=%d) to have a len of %d", len(callCount), 100)
28 }
29 }
30
31 func TestViaPollingPollsEvery10msscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/TestViaPollingPollsEvery10ms().(t *testingscip-go gomod github.com/golang/go/src go1.21.4 testing/.Tscip-go gomod github.com/golang/go/src go1.21.4 testing/T#) {
32 t.Parallelscip-go gomod github.com/golang/go/src go1.21.4 testing/T#Parallel().()
33 matcher := newMockMatcherscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/newMockMatcher().(t, timescip-go gomod github.com/golang/go/src go1.21.4 time/.Secondscip-go gomod github.com/golang/go/src go1.21.4 time/Second.)
34 m := matchersscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/.ViaPollingscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/ViaPolling().(matcher)
35
36 var ts []int64
37 f := func() int {
38 ts = append(ts, timescip-go gomod github.com/golang/go/src go1.21.4 time/.Nowscip-go gomod github.com/golang/go/src go1.21.4 time/Now().().UnixNanoscip-go gomod github.com/golang/go/src go1.21.4 time/Time#UnixNano().())
39 matcher.MatchOutputscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/mockMatcher#MatchOutput..ResultValuescip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/mockMatcher#$anon_1ee3ff7fc72ebcca#ResultValue. <- nil
40 matcher.MatchOutputscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/mockMatcher#MatchOutput..Errscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/mockMatcher#$anon_1ee3ff7fc72ebcca#Err. <- fmtscip-go gomod github.com/golang/go/src go1.21.4 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.21.4 fmt/Errorf().("still wrong")
41 return 99
42 }
43 m.Matchscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/ViaPollingMatcher#Match().(f)
44
45 for i := 0; i < len(ts)-1; i++ {
46 if ts[i+1]-ts[i] < int64(10*timescip-go gomod github.com/golang/go/src go1.21.4 time/.Millisecondscip-go gomod github.com/golang/go/src go1.21.4 time/Millisecond.) || ts[i+1]-ts[i] > int64(30*timescip-go gomod github.com/golang/go/src go1.21.4 time/.Millisecondscip-go gomod github.com/golang/go/src go1.21.4 time/Millisecond.) {
47 t.Fatalfscip-go gomod github.com/golang/go/src go1.21.4 testing/common#Fatalf().("expected %d to be within 10ms and 30ms", ts[i+1]-ts[i])
48 }
49 }
50 }
51
52 func TestViaPollingStopsAfterSuccessscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/TestViaPollingStopsAfterSuccess().(t *testingscip-go gomod github.com/golang/go/src go1.21.4 testing/.Tscip-go gomod github.com/golang/go/src go1.21.4 testing/T#) {
53 t.Parallelscip-go gomod github.com/golang/go/src go1.21.4 testing/T#Parallel().()
54 matcher := newMockMatcherscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/newMockMatcher().(t, timescip-go gomod github.com/golang/go/src go1.21.4 time/.Secondscip-go gomod github.com/golang/go/src go1.21.4 time/Second.)
55 m := matchersscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/.ViaPollingscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/ViaPolling().(matcher)
56
57 i := 0
58 callCount := make(chan bool, 200)
59 f := func() int {
60 i++
61 callCount <- true
62 matcher.MatchOutputscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/mockMatcher#MatchOutput..ResultValuescip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/mockMatcher#$anon_1ee3ff7fc72ebcca#ResultValue. <- i
63 matcher.MatchOutputscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/mockMatcher#MatchOutput..Errscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/mockMatcher#$anon_1ee3ff7fc72ebcca#Err. <- nil
64 return i
65 }
66
67 v, err := m.Matchscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/ViaPollingMatcher#Match().(f)
68 if err != nil {
69 t.Fatalscip-go gomod github.com/golang/go/src go1.21.4 testing/common#Fatal().("expected err to be nil")
70 }
71
72 if !reflectscip-go gomod github.com/golang/go/src go1.21.4 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.21.4 reflect/DeepEqual().(v, 1) {
73 t.Errorfscip-go gomod github.com/golang/go/src go1.21.4 testing/common#Errorf().("expected %v to equal %v", v, 1)
74 }
75
76 if len(callCount) != 1 {
77 t.Errorfscip-go gomod github.com/golang/go/src go1.21.4 testing/common#Errorf().("expected callCount (len=%d) to have a len of %d", len(callCount), 1)
78 }
79 }
80
81 func TestViaPollingUsesGivenPropertiesscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/TestViaPollingUsesGivenProperties().(t *testingscip-go gomod github.com/golang/go/src go1.21.4 testing/.Tscip-go gomod github.com/golang/go/src go1.21.4 testing/T#) {
82 t.Parallelscip-go gomod github.com/golang/go/src go1.21.4 testing/T#Parallel().()
83 matcher := newMockMatcherscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/newMockMatcher().(t, timescip-go gomod github.com/golang/go/src go1.21.4 time/.Secondscip-go gomod github.com/golang/go/src go1.21.4 time/Second.)
84 m := matchersscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/.ViaPollingMatcherscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/ViaPollingMatcher#{
85 Matcherscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/ViaPollingMatcher#Matcher.: matcher,
86 Durationscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/ViaPollingMatcher#Duration.: timescip-go gomod github.com/golang/go/src go1.21.4 time/.Millisecondscip-go gomod github.com/golang/go/src go1.21.4 time/Millisecond.,
87 Intervalscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/ViaPollingMatcher#Interval.: 100 * timescip-go gomod github.com/golang/go/src go1.21.4 time/.Microsecondscip-go gomod github.com/golang/go/src go1.21.4 time/Microsecond.,
88 }
89
90 callCount := make(chan bool, 200)
91 f := func() int {
92 callCount <- true
93 matcher.MatchOutputscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/mockMatcher#MatchOutput..ResultValuescip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/mockMatcher#$anon_1ee3ff7fc72ebcca#ResultValue. <- nil
94 matcher.MatchOutputscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/mockMatcher#MatchOutput..Errscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/mockMatcher#$anon_1ee3ff7fc72ebcca#Err. <- fmtscip-go gomod github.com/golang/go/src go1.21.4 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.21.4 fmt/Errorf().("still wrong")
95 return 99
96 }
97 m.Matchscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/ViaPollingMatcher#Match().(f)
98
99 if len(callCount) != 10 {
100 t.Errorfscip-go gomod github.com/golang/go/src go1.21.4 testing/common#Errorf().("expected callCount (len=%d) to have a len of %d", len(callCount), 10)
101 }
102 }
103
104 func TestViaPollingPassesAlongChanscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/TestViaPollingPassesAlongChan().(t *testingscip-go gomod github.com/golang/go/src go1.21.4 testing/.Tscip-go gomod github.com/golang/go/src go1.21.4 testing/T#) {
105 t.Parallelscip-go gomod github.com/golang/go/src go1.21.4 testing/T#Parallel().()
106 matcher := newMockMatcherscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/newMockMatcher().(t, timescip-go gomod github.com/golang/go/src go1.21.4 time/.Secondscip-go gomod github.com/golang/go/src go1.21.4 time/Second.)
107 m := matchersscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/.ViaPollingscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/ViaPolling().(matcher)
108 matcher.MatchOutputscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/mockMatcher#MatchOutput..ResultValuescip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/mockMatcher#$anon_1ee3ff7fc72ebcca#ResultValue. <- nil
109 matcher.MatchOutputscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/mockMatcher#MatchOutput..Errscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/mockMatcher#$anon_1ee3ff7fc72ebcca#Err. <- nil
110
111 c := make(chan int)
112 m.Matchscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/ViaPollingMatcher#Match().(c)
113
114 if len(matcher.MatchInputscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/mockMatcher#MatchInput..Actualscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/mockMatcher#$anon_0414ddec28f93254#Actual.) != 1 {
115 t.Errorfscip-go gomod github.com/golang/go/src go1.21.4 testing/common#Errorf().("expected Actual (len=%d) to have a len of %d", len(matcher.MatchInputscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/mockMatcher#MatchInput..Actualscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/mockMatcher#$anon_0414ddec28f93254#Actual.), 1)
116 }
117
118 actual := <-matcher.MatchInputscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/mockMatcher#MatchInput..Actualscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/mockMatcher#$anon_0414ddec28f93254#Actual.
119 if !reflectscip-go gomod github.com/golang/go/src go1.21.4 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.21.4 reflect/DeepEqual().(actual, c) {
120 t.Errorfscip-go gomod github.com/golang/go/src go1.21.4 testing/common#Errorf().("expected %v to equal %v", actual, c)
121 }
122 }
123
124 func TestViaPollingFailsForNonChanOrFuncscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/TestViaPollingFailsForNonChanOrFunc().(t *testingscip-go gomod github.com/golang/go/src go1.21.4 testing/.Tscip-go gomod github.com/golang/go/src go1.21.4 testing/T#) {
125 t.Parallelscip-go gomod github.com/golang/go/src go1.21.4 testing/T#Parallel().()
126 matcher := newMockMatcherscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/newMockMatcher().(t, timescip-go gomod github.com/golang/go/src go1.21.4 time/.Secondscip-go gomod github.com/golang/go/src go1.21.4 time/Second.)
127 m := matchersscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/.ViaPollingscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/ViaPolling().(matcher)
128
129 _, err := m.Matchscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/ViaPollingMatcher#Match().(101)
130 if err == nil {
131 t.Errorscip-go gomod github.com/golang/go/src go1.21.4 testing/common#Error().("expected err to not be nil")
132 }
133 }
134
135 func TestViaPollingFailsForFuncWithArgsscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/TestViaPollingFailsForFuncWithArgs().(t *testingscip-go gomod github.com/golang/go/src go1.21.4 testing/.Tscip-go gomod github.com/golang/go/src go1.21.4 testing/T#) {
136 t.Parallelscip-go gomod github.com/golang/go/src go1.21.4 testing/T#Parallel().()
137 matcher := newMockMatcherscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/newMockMatcher().(t, timescip-go gomod github.com/golang/go/src go1.21.4 time/.Secondscip-go gomod github.com/golang/go/src go1.21.4 time/Second.)
138 m := matchersscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/.ViaPollingscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/ViaPolling().(matcher)
139
140 _, err := m.Matchscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/ViaPollingMatcher#Match().(func(int) int { return 101 })
141 if err == nil {
142 t.Errorscip-go gomod github.com/golang/go/src go1.21.4 testing/common#Error().("expected err to not be nil")
143 }
144 }
145
146 func TestViaPollingFailsForFuncWithWrongReturnsscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/TestViaPollingFailsForFuncWithWrongReturns().(t *testingscip-go gomod github.com/golang/go/src go1.21.4 testing/.Tscip-go gomod github.com/golang/go/src go1.21.4 testing/T#) {
147 t.Parallelscip-go gomod github.com/golang/go/src go1.21.4 testing/T#Parallel().()
148 matcher := newMockMatcherscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/newMockMatcher().(t, timescip-go gomod github.com/golang/go/src go1.21.4 time/.Secondscip-go gomod github.com/golang/go/src go1.21.4 time/Second.)
149 m := matchersscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/.ViaPollingscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/ViaPolling().(matcher)
150
151 _, err := m.Matchscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/ViaPollingMatcher#Match().(func() (int, int) { return 101, 103 })
152 if err == nil {
153 t.Errorscip-go gomod github.com/golang/go/src go1.21.4 testing/common#Error().("expected err to not be nil")
154 }
155 }
156
157 func TestViaPollingFailsForSendOnlyChanscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/TestViaPollingFailsForSendOnlyChan().(t *testingscip-go gomod github.com/golang/go/src go1.21.4 testing/.Tscip-go gomod github.com/golang/go/src go1.21.4 testing/T#) {
158 t.Parallelscip-go gomod github.com/golang/go/src go1.21.4 testing/T#Parallel().()
159 matcher := newMockMatcherscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/newMockMatcher().(t, timescip-go gomod github.com/golang/go/src go1.21.4 time/.Secondscip-go gomod github.com/golang/go/src go1.21.4 time/Second.)
160 m := matchersscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/.ViaPollingscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/ViaPolling().(matcher)
161
162 _, err := m.Matchscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/ViaPollingMatcher#Match().(make(chan<- int))
163 if err == nil {
164 t.Errorscip-go gomod github.com/golang/go/src go1.21.4 testing/common#Error().("expected err to not be nil")
165 }
166 }
167
168 func TestViaPollingUsesChildMatcherErrscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/TestViaPollingUsesChildMatcherErr().(t *testingscip-go gomod github.com/golang/go/src go1.21.4 testing/.Tscip-go gomod github.com/golang/go/src go1.21.4 testing/T#) {
169 t.Parallelscip-go gomod github.com/golang/go/src go1.21.4 testing/T#Parallel().()
170 matcher := newMockMatcherscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/newMockMatcher().(t, timescip-go gomod github.com/golang/go/src go1.21.4 time/.Secondscip-go gomod github.com/golang/go/src go1.21.4 time/Second.)
171 m := matchersscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/.ViaPollingscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/ViaPolling().(matcher)
172
173 f := func() int {
174 matcher.MatchOutputscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/mockMatcher#MatchOutput..Errscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/mockMatcher#$anon_1ee3ff7fc72ebcca#Err. <- fmtscip-go gomod github.com/golang/go/src go1.21.4 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.21.4 fmt/Errorf().("some-message")
175 matcher.MatchOutputscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/mockMatcher#MatchOutput..ResultValuescip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers_test`/mockMatcher#$anon_1ee3ff7fc72ebcca#ResultValue. <- nil
176 return 99
177 }
178 _, err := m.Matchscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/ViaPollingMatcher#Match().(f)
179
180 if err == nil {
181 t.Fatalscip-go gomod github.com/golang/go/src go1.21.4 testing/common#Fatal().("expected err to not be nil")
182 }
183
184 if err.Error() != "some-message" {
185 t.Errorfscip-go gomod github.com/golang/go/src go1.21.4 testing/common#Errorf().("expected err to have message: %s", "some-message")
186 }
187 }