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

Function TestGenericArrayScanErrors

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

Source from the content-addressed store, hash-verified

1089}
1090
1091func TestGenericArrayScanErrors(t *testing.T) {
1092 var sa [1]string
1093 var nis []sql.NullInt64
1094 var pss *[]string
1095
1096 for _, tt := range []struct {
1097 src, dest any
1098 err string
1099 }{
1100 {nil, pss, "destination *[]string is nil"},
1101 {`{`, &sa, "unable to parse"},
1102 {`{}`, &sa, "cannot convert ARRAY[0] to [1]string"},
1103 {`{x,x}`, &sa, "cannot convert ARRAY[2] to [1]string"},
1104 {`{x}`, &nis, `parsing array element index 0: converting`},
1105 } {
1106 err := GenericArray{tt.dest}.Scan(tt.src)
1107
1108 if err == nil {
1109 t.Fatalf("Expected error for [%#v %#v]", tt.src, tt.dest)
1110 }
1111 if !strings.Contains(err.Error(), tt.err) {
1112 t.Errorf("Expected error to contain %q for [%#v %#v], got %q", tt.err, tt.src, tt.dest, err)
1113 }
1114 }
1115}
1116
1117func TestGenericArrayValueUnsupported(t *testing.T) {
1118 _, err := GenericArray{true}.Value()

Callers

nothing calls this directly

Calls 2

ScanMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…