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

Function TestAllowRefresh

coderd/entitlements/entitlements_test.go:30–50  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

28}
29
30func TestAllowRefresh(t *testing.T) {
31 t.Parallel()
32
33 now := time.Now()
34 set := entitlements.New()
35 set.Modify(func(entitlements *codersdk.Entitlements) {
36 entitlements.RefreshedAt = now
37 })
38
39 ok, wait := set.AllowRefresh(now)
40 require.False(t, ok)
41 require.InDelta(t, time.Minute.Seconds(), wait.Seconds(), 5)
42
43 set.Modify(func(entitlements *codersdk.Entitlements) {
44 entitlements.RefreshedAt = now.Add(time.Minute * -2)
45 })
46
47 ok, wait = set.AllowRefresh(now)
48 require.True(t, ok)
49 require.Equal(t, time.Duration(0), wait)
50}
51
52func TestUpdate(t *testing.T) {
53 t.Parallel()

Callers

nothing calls this directly

Calls 6

NewFunction · 0.92
ModifyMethod · 0.80
AllowRefreshMethod · 0.80
DurationMethod · 0.80
AddMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected