MCPcopy Index your code
hub / github.com/coder/coder / TestNotifier

Function TestNotifier

coderd/autobuild/notify/notifier_test.go:15–117  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13)
14
15func TestNotifier(t *testing.T) {
16 t.Parallel()
17
18 now := time.Date(2022, 5, 13, 0, 0, 0, 0, time.UTC)
19
20 testCases := []struct {
21 Name string
22 Countdown []time.Duration
23 PollInterval time.Duration
24 NTicks int
25 ConditionDeadline time.Time
26 NumConditions int
27 NumCallbacks int
28 }{
29 {
30 Name: "zero deadline",
31 Countdown: durations(),
32 PollInterval: time.Second,
33 NTicks: 0,
34 ConditionDeadline: time.Time{},
35 NumConditions: 1,
36 NumCallbacks: 0,
37 },
38 {
39 Name: "no calls",
40 Countdown: durations(),
41 PollInterval: time.Second,
42 NTicks: 0,
43 ConditionDeadline: now,
44 NumConditions: 1,
45 NumCallbacks: 0,
46 },
47 {
48 Name: "exactly one call",
49 Countdown: durations(time.Second),
50 PollInterval: time.Second,
51 NTicks: 1,
52 ConditionDeadline: now.Add(time.Second),
53 NumConditions: 2,
54 NumCallbacks: 1,
55 },
56 {
57 Name: "two calls",
58 Countdown: durations(4*time.Second, 2*time.Second),
59 PollInterval: time.Second,
60 NTicks: 5,
61 ConditionDeadline: now.Add(5 * time.Second),
62 NumConditions: 6,
63 NumCallbacks: 2,
64 },
65 {
66 Name: "wrong order should not matter",
67 Countdown: durations(2*time.Second, 4*time.Second),
68 PollInterval: time.Second,
69 NTicks: 5,
70 ConditionDeadline: now.Add(5 * time.Second),
71 NumConditions: 6,
72 NumCallbacks: 2,

Callers

nothing calls this directly

Calls 9

ContextFunction · 0.92
NewFunction · 0.92
WithTestClockFunction · 0.92
durationsFunction · 0.85
AddMethod · 0.65
RunMethod · 0.65
SetMethod · 0.65
CloseMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected