MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / TestDuration

Function TestDuration

env/types_test.go:148–174  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

146}
147
148func TestDuration(t *testing.T) {
149 tests := []struct {
150 input string
151 want time.Duration
152 wantErr bool
153 }{
154 {input: "30", want: 30 * time.Second},
155 {input: "not-a-number", wantErr: true},
156 }
157
158 for _, tt := range tests {
159 t.Run(tt.input, func(t *testing.T) {
160 t.Setenv(testVar, tt.input)
161 desc := env.Duration(testVar)
162
163 var result time.Duration
164 err := desc.Parse(&result)
165
166 if tt.wantErr {
167 require.Error(t, err)
168 } else {
169 require.NoError(t, err)
170 assert.Equal(t, tt.want, result)
171 }
172 })
173 }
174}
175
176func TestDurationMillis(t *testing.T) {
177 tests := []struct {

Callers

nothing calls this directly

Calls 4

DurationFunction · 0.92
RunMethod · 0.80
ParseMethod · 0.80
ErrorMethod · 0.65

Tested by

no test coverage detected