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

Function TestStringArrayScanError

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

Source from the content-addressed store, hash-verified

888}
889
890func TestStringArrayScanError(t *testing.T) {
891 for _, tt := range []struct {
892 input, err string
893 }{
894 {``, "unable to parse array"},
895 {`{`, "unable to parse array"},
896 {`{{a},{b}}`, "cannot convert ARRAY[2][1] to StringArray"},
897 {`{NULL}`, "parsing array element index 0: cannot convert nil to string"},
898 {`{a,NULL}`, "parsing array element index 1: cannot convert nil to string"},
899 {`{a,b,NULL}`, "parsing array element index 2: cannot convert nil to string"},
900 } {
901 arr := StringArray{"x", "x", "x"}
902 err := arr.Scan(tt.input)
903
904 if err == nil {
905 t.Fatalf("Expected error for %q, got none", tt.input)
906 }
907 if !strings.Contains(err.Error(), tt.err) {
908 t.Errorf("Expected error to contain %q for %q, got %q", tt.err, tt.input, err)
909 }
910 if !reflect.DeepEqual(arr, StringArray{"x", "x", "x"}) {
911 t.Errorf("Expected destination not to change for %q, got %+v", tt.input, arr)
912 }
913 }
914}
915
916func TestStringArrayValue(t *testing.T) {
917 result, err := StringArray(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…