MCPcopy
hub / github.com/cilium/cilium / TestFromString

Function TestFromString

hubble/pkg/time/time_test.go:11–74  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestFromString(t *testing.T) {
12 restore := hijackNow()
13 defer restore()
14
15 tests := []struct {
16 input string
17 expected string
18 }{
19 {
20 input: "10s",
21 expected: "2019-07-01T13:59:50Z",
22 },
23 {
24 input: "5m",
25 expected: "2019-07-01T13:55:00Z",
26 },
27 {
28 input: "20h",
29 expected: "2019-06-30T18:00:00Z",
30 },
31 {
32 input: "2019-06-30T18:00:00Z",
33 expected: "2019-06-30T18:00:00Z",
34 },
35 {
36 input: "2019-06-30",
37 expected: "2019-06-30T00:00:00Z",
38 },
39 {
40 input: "2019-06-30T18Z",
41 expected: "2019-06-30T18:00:00Z",
42 },
43 {
44 input: "2019-06-30T18:45Z",
45 expected: "2019-06-30T18:45:00Z",
46 },
47 {
48 input: "2019-06-30T18+02:00",
49 expected: "2019-06-30T16:00:00Z",
50 },
51 {
52 input: "2019-06-30T18:45+02:00",
53 expected: "2019-06-30T16:45:00Z",
54 },
55 }
56
57 for _, tt := range tests {
58 t.Run(tt.input, func(t *testing.T) {
59 got, err := FromString(tt.input)
60 if err != nil {
61 t.Errorf("failed to parse %s", tt.input)
62 }
63
64 expected, err := FromString(tt.expected)
65 if err != nil {
66 t.Errorf("failed to parse %s", tt.expected)
67 }
68

Callers

nothing calls this directly

Calls 5

hijackNowFunction · 0.85
FromStringFunction · 0.70
RunMethod · 0.65
EqualMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…