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

Function TestInt

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

Source from the content-addressed store, hash-verified

87}
88
89func TestInt(t *testing.T) {
90 tests := []struct {
91 input string
92 want int
93 wantErr bool
94 }{
95 {input: "42", want: 42},
96 {input: "-1", want: -1},
97 {input: "not-a-number", wantErr: true},
98 }
99
100 for _, tt := range tests {
101 t.Run(tt.input, func(t *testing.T) {
102 t.Setenv(testVar, tt.input)
103 desc := env.Int(testVar)
104
105 var result int
106 err := desc.Parse(&result)
107
108 if tt.wantErr {
109 require.Error(t, err)
110 } else {
111 require.NoError(t, err)
112 assert.Equal(t, tt.want, result)
113 }
114 })
115 }
116}
117
118func TestMegaInt(t *testing.T) {
119 tests := []struct {

Callers

nothing calls this directly

Calls 4

IntFunction · 0.92
RunMethod · 0.80
ParseMethod · 0.80
ErrorMethod · 0.65

Tested by

no test coverage detected