nolint:tparallel,paralleltest
(t *testing.T)
| 668 | |
| 669 | //nolint:tparallel,paralleltest |
| 670 | func TestParseChatWorkspaceTTL(t *testing.T) { |
| 671 | t.Parallel() |
| 672 | |
| 673 | tests := []struct { |
| 674 | name string |
| 675 | input string |
| 676 | want time.Duration |
| 677 | wantErr bool |
| 678 | }{ |
| 679 | {"Empty_ReturnsDefault", "", 0, false}, |
| 680 | {"ValidDuration_Hours", "2h", 2 * time.Hour, false}, |
| 681 | {"ValidDuration_HoursAndMinutes", "2h30m", 2*time.Hour + 30*time.Minute, false}, |
| 682 | {"ValidDuration_Minutes", "90m", 90 * time.Minute, false}, |
| 683 | {"Zero", "0s", 0, false}, |
| 684 | {"Negative", "-1h", 0, true}, |
| 685 | {"Invalid", "not-a-duration", 0, true}, |
| 686 | {"LargeDuration", "720h", 720 * time.Hour, false}, |
| 687 | } |
| 688 | for _, tc := range tests { |
| 689 | t.Run(tc.name, func(t *testing.T) { |
| 690 | got, err := codersdk.ParseChatWorkspaceTTL(tc.input) |
| 691 | if tc.wantErr { |
| 692 | require.Error(t, err) |
| 693 | return |
| 694 | } |
| 695 | require.NoError(t, err) |
| 696 | require.Equal(t, tc.want, got) |
| 697 | }) |
| 698 | } |
| 699 | } |
nothing calls this directly
no test coverage detected