MCPcopy Index your code
hub / github.com/aarondl/sqlboiler / TestBoolArrayScanError

Function TestBoolArrayScanError

types/array_test.go:272–297  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

270}
271
272func TestBoolArrayScanError(t *testing.T) {
273 for _, tt := range []struct {
274 input, err string
275 }{
276 {``, "unable to parse array"},
277 {`{`, "unable to parse array"},
278 {`{{t},{f}}`, "cannot convert ARRAY[2][1] to BoolArray"},
279 {`{NULL}`, `could not parse boolean array index 0: invalid boolean ""`},
280 {`{a}`, `could not parse boolean array index 0: invalid boolean "a"`},
281 {`{t,b}`, `could not parse boolean array index 1: invalid boolean "b"`},
282 {`{t,f,cd}`, `could not parse boolean array index 2: invalid boolean "cd"`},
283 } {
284 arr := BoolArray{true, true, true}
285 err := arr.Scan(tt.input)
286
287 if err == nil {
288 t.Fatalf("Expected error for %q, got none", tt.input)
289 }
290 if !strings.Contains(err.Error(), tt.err) {
291 t.Errorf("Expected error to contain %q for %q, got %q", tt.err, tt.input, err)
292 }
293 if !reflect.DeepEqual(arr, BoolArray{true, true, true}) {
294 t.Errorf("Expected destination not to change for %q, got %+v", tt.input, arr)
295 }
296 }
297}
298
299func TestBoolArrayValue(t *testing.T) {
300 result, err := BoolArray(nil).Value()

Callers

nothing calls this directly

Calls 2

ScanMethod · 0.95
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…