(t *testing.T)
| 1482 | } |
| 1483 | |
| 1484 | func TestConfigDuration(t *testing.T) { |
| 1485 | tests := []struct { |
| 1486 | duration time.Duration |
| 1487 | expectedJSON string |
| 1488 | inputJSON string |
| 1489 | }{ |
| 1490 | { |
| 1491 | duration: 0, |
| 1492 | expectedJSON: `"0s"`, |
| 1493 | inputJSON: `"0"`, |
| 1494 | }, |
| 1495 | { |
| 1496 | duration: 123 * time.Nanosecond, |
| 1497 | expectedJSON: `"123ns"`, |
| 1498 | inputJSON: `"123ns"`, |
| 1499 | }, |
| 1500 | { |
| 1501 | duration: 1234 * time.Nanosecond, |
| 1502 | expectedJSON: `"1.234µs"`, |
| 1503 | inputJSON: `"1234ns"`, |
| 1504 | }, |
| 1505 | { |
| 1506 | duration: 250 * time.Millisecond, |
| 1507 | expectedJSON: `"250ms"`, |
| 1508 | inputJSON: `"0.25s"`, |
| 1509 | }, |
| 1510 | { |
| 1511 | duration: 15 * time.Millisecond, |
| 1512 | expectedJSON: `"15ms"`, |
| 1513 | inputJSON: `"15ms"`, |
| 1514 | }, |
| 1515 | { |
| 1516 | duration: 5 * time.Second, |
| 1517 | expectedJSON: `"5s"`, |
| 1518 | inputJSON: `"5s"`, |
| 1519 | }, |
| 1520 | // Times >= 1minute are formatted with 0 minutes and seconds |
| 1521 | { |
| 1522 | duration: 25 * time.Minute, |
| 1523 | expectedJSON: `"25m0s"`, |
| 1524 | inputJSON: `"25m"`, |
| 1525 | }, |
| 1526 | { |
| 1527 | duration: 2 * time.Hour, |
| 1528 | expectedJSON: `"2h0m0s"`, |
| 1529 | inputJSON: `"2h"`, |
| 1530 | }, |
| 1531 | { |
| 1532 | duration: 2*time.Hour + 13*time.Minute + 10*time.Second, |
| 1533 | expectedJSON: `"2h13m10s"`, |
| 1534 | inputJSON: `"2h13m10s"`, |
| 1535 | }, |
| 1536 | // no units larger than an hour |
| 1537 | { |
| 1538 | duration: 48 * time.Hour, |
| 1539 | expectedJSON: `"48h0m0s"`, |
| 1540 | inputJSON: `"48h"`, |
| 1541 | }, |
nothing calls this directly
no test coverage detected