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

Function TestMegaInt

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

Source from the content-addressed store, hash-verified

116}
117
118func TestMegaInt(t *testing.T) {
119 tests := []struct {
120 input string
121 want int
122 wantErr bool
123 }{
124 {input: "1.5", want: 1_500_000},
125 {input: "2", want: 2_000_000},
126 {input: "0.5", want: 500_000},
127 {input: "invalid", wantErr: true},
128 }
129
130 for _, tt := range tests {
131 t.Run(tt.input, func(t *testing.T) {
132 t.Setenv(testVar, tt.input)
133 desc := env.MegaInt(testVar)
134
135 var result int
136 err := desc.Parse(&result)
137
138 if tt.wantErr {
139 require.Error(t, err)
140 } else {
141 require.NoError(t, err)
142 assert.Equal(t, tt.want, result)
143 }
144 })
145 }
146}
147
148func TestDuration(t *testing.T) {
149 tests := []struct {

Callers

nothing calls this directly

Calls 4

MegaIntFunction · 0.92
RunMethod · 0.80
ParseMethod · 0.80
ErrorMethod · 0.65

Tested by

no test coverage detected