MCPcopy Index your code
hub / github.com/tailscale/tailscale / TestClockSetStep

Function TestClockSetStep

tstest/clock_test.go:164–310  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

162}
163
164func TestClockSetStep(t *testing.T) {
165 t.Parallel()
166
167 type stepInfo struct {
168 when int
169 step time.Duration
170 }
171
172 tests := []struct {
173 name string
174 start time.Time
175 step time.Duration
176 stepChanges []stepInfo
177 wants []time.Time // The return values of sequential calls to Now().
178 }{
179 {
180 name: "increment-ms-then-s",
181 start: time.Unix(12345, 1000),
182 step: 1000,
183 stepChanges: []stepInfo{
184 {
185 when: 4,
186 step: time.Second,
187 },
188 },
189 wants: []time.Time{
190 time.Unix(12345, 1000),
191 time.Unix(12345, 2000),
192 time.Unix(12345, 3000),
193 time.Unix(12345, 4000),
194 time.Unix(12346, 4000),
195 time.Unix(12347, 4000),
196 time.Unix(12348, 4000),
197 time.Unix(12349, 4000),
198 },
199 },
200 {
201 name: "multiple-changes-over-time",
202 start: time.Unix(12345, 1000),
203 step: 1,
204 stepChanges: []stepInfo{
205 {
206 when: 2,
207 step: time.Second,
208 },
209 {
210 when: 4,
211 step: 0,
212 },
213 {
214 when: 6,
215 step: 1000,
216 },
217 },
218 wants: []time.Time{
219 time.Unix(12345, 1000),
220 time.Unix(12345, 1001),
221 time.Unix(12346, 1001),

Callers

nothing calls this directly

Calls 9

SetStepMethod · 0.95
GetStartMethod · 0.95
GetStepMethod · 0.95
NowMethod · 0.95
PeekNowMethod · 0.95
NewClockFunction · 0.85
RunMethod · 0.65
EqualMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…