| 190 | } |
| 191 | |
| 192 | func TestStatic_Duration(t *testing.T) { |
| 193 | tests := []struct { |
| 194 | arg any |
| 195 | ok bool |
| 196 | }{ |
| 197 | // supported values |
| 198 | {arg: time.Duration(0), ok: true}, |
| 199 | {arg: time.Duration(1), ok: true}, |
| 200 | {arg: time.Duration(100) * time.Second, ok: true}, |
| 201 | // unsupported values |
| 202 | {arg: 1}, |
| 203 | {arg: 3.14}, |
| 204 | {arg: "test"}, |
| 205 | {arg: true}, |
| 206 | {arg: StatusOk}, |
| 207 | {arg: KindClient}, |
| 208 | {arg: []int{1, 2, 3}}, |
| 209 | {arg: []float64{1.0, 2.2}}, |
| 210 | {arg: []bool{true, true}}, |
| 211 | {arg: []string{"aa", "bb"}}, |
| 212 | } |
| 213 | |
| 214 | for _, tt := range tests { |
| 215 | t.Run(testName(tt.arg), func(t *testing.T) { |
| 216 | static := newStatic(tt.arg) |
| 217 | d, ok := static.Duration() |
| 218 | |
| 219 | require.Equal(t, tt.ok, ok) |
| 220 | if tt.ok { |
| 221 | assert.Equal(t, tt.arg, d) |
| 222 | } |
| 223 | }) |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | func TestStatic_Status(t *testing.T) { |
| 228 | tests := []struct { |