(t *testing.T)
| 26 | ) |
| 27 | |
| 28 | func TestAPIHelpers(t *testing.T) { |
| 29 | t.Run("BoolPtr", func(t *testing.T) { |
| 30 | v := BoolPtr(false) |
| 31 | if v == nil || *v != false { |
| 32 | t.Errorf("Expected false, got: %v", v) |
| 33 | } |
| 34 | |
| 35 | v = BoolPtr(true) |
| 36 | if v == nil || *v != true { |
| 37 | t.Errorf("Expected true, got: %v", v) |
| 38 | } |
| 39 | }) |
| 40 | |
| 41 | t.Run("IntPtr", func(t *testing.T) { |
| 42 | v := IntPtr(0) |
| 43 | if v == nil || *v != 0 { |
| 44 | t.Errorf("Expected 0, got: %v", v) |
| 45 | } |
| 46 | }) |
| 47 | |
| 48 | t.Run("FormatDuration", func(t *testing.T) { |
| 49 | var tt = []struct { |
| 50 | duration time.Duration |
| 51 | expected string |
| 52 | }{ |
| 53 | {1 * time.Nanosecond, "1nanos"}, |
| 54 | {100 * time.Nanosecond, "100nanos"}, |
| 55 | {1 * time.Microsecond, "1000nanos"}, |
| 56 | {1 * time.Millisecond, "1ms"}, |
| 57 | {100 * time.Millisecond, "100ms"}, |
| 58 | {1 * time.Minute, "60000ms"}, |
| 59 | {10 * time.Minute, "600000ms"}, |
| 60 | {1 * time.Hour, "3600000ms"}, |
| 61 | {10 * time.Hour, "36000000ms"}, |
| 62 | } |
| 63 | |
| 64 | for _, tc := range tt { |
| 65 | actual := formatDuration(tc.duration) |
| 66 | if actual != tc.expected { |
| 67 | t.Errorf("Unexpected output: got=%s, want=%s", actual, tc.expected) |
| 68 | } |
| 69 | } |
| 70 | }) |
| 71 | } |
nothing calls this directly
no test coverage detected