(t *testing.T)
| 62 | } |
| 63 | |
| 64 | func TestParseTime(t *testing.T) { |
| 65 | var tests = []struct { |
| 66 | input string |
| 67 | fail bool |
| 68 | result time.Time |
| 69 | }{ |
| 70 | { |
| 71 | input: "", |
| 72 | fail: true, |
| 73 | }, { |
| 74 | input: "abc", |
| 75 | fail: true, |
| 76 | }, { |
| 77 | input: "30s", |
| 78 | fail: true, |
| 79 | }, { |
| 80 | input: "123", |
| 81 | result: time.Unix(123, 0), |
| 82 | }, { |
| 83 | input: "123.123", |
| 84 | result: time.Unix(123, 123000000), |
| 85 | }, { |
| 86 | input: "2015-06-03T13:21:58.555Z", |
| 87 | result: time.Unix(1433337718, 555*time.Millisecond.Nanoseconds()), |
| 88 | }, { |
| 89 | input: "2015-06-03T14:21:58.555+01:00", |
| 90 | result: time.Unix(1433337718, 555*time.Millisecond.Nanoseconds()), |
| 91 | }, { |
| 92 | // Test nanosecond rounding. |
| 93 | input: "2015-06-03T13:21:58.56789Z", |
| 94 | result: time.Unix(1433337718, 567*1e6), |
| 95 | }, { |
| 96 | // Test float rounding. |
| 97 | input: "1543578564.705", |
| 98 | result: time.Unix(1543578564, 705*1e6), |
| 99 | }, |
| 100 | } |
| 101 | |
| 102 | for _, test := range tests { |
| 103 | ts, err := ParseTime(test.input) |
| 104 | if test.fail { |
| 105 | require.Error(t, err) |
| 106 | continue |
| 107 | } |
| 108 | |
| 109 | require.NoError(t, err) |
| 110 | assert.Equal(t, TimeToMillis(test.result), ts) |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | func TestNewDisableableTicker_Enabled(t *testing.T) { |
| 115 | stop, ch := NewDisableableTicker(10 * time.Millisecond) |
nothing calls this directly
no test coverage detected