MCPcopy Index your code
hub / github.com/coder/coder / TestParseChatWorkspaceTTL

Function TestParseChatWorkspaceTTL

codersdk/chats_test.go:670–699  ·  view source on GitHub ↗

nolint:tparallel,paralleltest

(t *testing.T)

Source from the content-addressed store, hash-verified

668
669//nolint:tparallel,paralleltest
670func 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}

Callers

nothing calls this directly

Calls 4

ParseChatWorkspaceTTLFunction · 0.92
RunMethod · 0.65
ErrorMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected