(t *testing.T)
| 9 | ) |
| 10 | |
| 11 | func 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 |
nothing calls this directly
no test coverage detected
searching dependent graphs…