(t *testing.T)
| 3108 | wantErr bool |
| 3109 | isBinary bool |
| 3110 | tableName string |
| 3111 | columnList string |
| 3112 | }{ |
| 3113 | { |
| 3114 | name: "COPY with FORMAT binary", |
| 3115 | query: "COPY users FROM STDIN (FORMAT binary)", |
| 3116 | isBinary: true, |
| 3117 | tableName: "users", |
| 3118 | }, |
| 3119 | { |
| 3120 | name: "COPY with columns and FORMAT binary", |
| 3121 | query: "COPY users (id, name) FROM STDIN (FORMAT binary)", |
| 3122 | isBinary: true, |
| 3123 | tableName: "users", |
| 3124 | columnList: "(id, name)", |
| 3125 | }, |
| 3126 | { |
| 3127 | name: "COPY CSV is not binary", |
| 3128 | query: "COPY users FROM STDIN CSV", |
| 3129 | isBinary: false, |
| 3130 | tableName: "users", |
| 3131 | }, |
| 3132 | { |
| 3133 | name: "COPY text format is not binary", |
| 3134 | query: "COPY users FROM STDIN", |
| 3135 | isBinary: false, |
| 3136 | tableName: "users", |
| 3137 | }, |
| 3138 | } |
| 3139 | |
| 3140 | for _, tt := range tests { |
| 3141 | t.Run(tt.name, func(t *testing.T) { |
| 3142 | opts, err := ParseCopyFromOptions(tt.query) |
| 3143 | if tt.wantErr { |
| 3144 | if err == nil { |
| 3145 | t.Fatal("expected error") |
| 3146 | return |
| 3147 | } |
| 3148 | return |
| 3149 | } |
| 3150 | if err != nil { |
| 3151 | t.Fatalf("ParseCopyFromOptions(%q) error: %v", tt.query, err) |
| 3152 | } |
| 3153 | if opts.IsBinary != tt.isBinary { |
| 3154 | t.Errorf("IsBinary = %v, want %v", opts.IsBinary, tt.isBinary) |
| 3155 | } |
| 3156 | if opts.TableName != tt.tableName { |
| 3157 | t.Errorf("TableName = %q, want %q", opts.TableName, tt.tableName) |
| 3158 | } |
| 3159 | if tt.columnList != "" && opts.ColumnList != tt.columnList { |
| 3160 | t.Errorf("ColumnList = %q, want %q", opts.ColumnList, tt.columnList) |
| 3161 | } |
| 3162 | }) |
| 3163 | } |
| 3164 | } |
| 3165 | |
| 3166 | func TestDecodeBinaryCopy(t *testing.T) { |
| 3167 | tests := []struct { |
nothing calls this directly
no test coverage detected