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

Function TestBool

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

Source from the content-addressed store, hash-verified

27}
28
29func TestBool(t *testing.T) {
30 tests := []struct {
31 input string
32 want bool
33 wantErr bool
34 }{
35 {input: "true", want: true},
36 {input: "false", want: false},
37 {input: "1", want: true},
38 {input: "0", want: false},
39 {input: "invalid", wantErr: true},
40 }
41
42 for _, tt := range tests {
43 t.Run(tt.input, func(t *testing.T) {
44 t.Setenv(testVar, tt.input)
45 desc := env.Bool(testVar)
46
47 var result bool
48 err := desc.Parse(&result)
49
50 if tt.wantErr {
51 require.Error(t, err)
52 } else {
53 require.NoError(t, err)
54 assert.Equal(t, tt.want, result)
55 }
56 })
57 }
58}
59
60func TestFloat(t *testing.T) {
61 tests := []struct {

Callers

nothing calls this directly

Calls 4

BoolFunction · 0.92
RunMethod · 0.80
ParseMethod · 0.80
ErrorMethod · 0.65

Tested by

no test coverage detected