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

Function TestDurationDisplay

cli/util_internal_test.go:11–41  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestDurationDisplay(t *testing.T) {
12 t.Parallel()
13 for _, testCase := range []struct {
14 Duration string
15 Expected string
16 }{
17 {"-1s", "<1m"},
18 {"0s", "0s"},
19 {"1s", "<1m"},
20 {"59s", "<1m"},
21 {"1m", "1m"},
22 {"1m1s", "1m"},
23 {"2m", "2m"},
24 {"59m", "59m"},
25 {"1h", "1h"},
26 {"1h1m1s", "1h1m"},
27 {"2h", "2h"},
28 {"23h", "23h"},
29 {"24h", "1d"},
30 {"24h1m1s", "1d"},
31 {"25h", "1d1h"},
32 } {
33 t.Run(testCase.Duration, func(t *testing.T) {
34 t.Parallel()
35 d, err := time.ParseDuration(testCase.Duration)
36 require.NoError(t, err)
37 actual := durationDisplay(d)
38 assert.Equal(t, testCase.Expected, actual)
39 })
40 }
41}
42
43func TestExtendedParseDuration(t *testing.T) {
44 t.Parallel()

Callers

nothing calls this directly

Calls 3

durationDisplayFunction · 0.85
RunMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected