MCPcopy Create free account
hub / github.com/gotenberg/gotenberg / TestFormData_Bool

Function TestFormData_Bool

pkg/modules/api/formdata_test.go:165–245  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

163}
164
165func TestFormData_Bool(t *testing.T) {
166 for _, tc := range []struct {
167 scenario string
168 form *FormData
169 defaultValue bool
170 expect bool
171 expectError bool
172 }{
173 {
174 scenario: "key does not exist, fallback to default zero value",
175 form: &FormData{},
176 defaultValue: false,
177 expect: false,
178 expectError: false,
179 },
180 {
181 scenario: "key does not exist, fallback to default value",
182 form: &FormData{},
183 defaultValue: true,
184 expect: true,
185 expectError: false,
186 },
187 {
188 scenario: "key does exist, but empty value, fallback to default value",
189 form: &FormData{
190 values: map[string][]string{
191 "foo": {
192 "",
193 },
194 },
195 },
196 defaultValue: false,
197 expect: false,
198 expectError: false,
199 },
200 {
201 scenario: "key does exist, but value is invalid",
202 form: &FormData{
203 values: map[string][]string{
204 "foo": {
205 "foo",
206 },
207 },
208 },
209 defaultValue: false,
210 expect: false,
211 expectError: true,
212 },
213 {
214 scenario: "key does exist with a value",
215 form: &FormData{
216 values: map[string][]string{
217 "foo": {
218 "true",
219 },
220 },
221 },
222 defaultValue: false,

Callers

nothing calls this directly

Calls 2

BoolMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected