MCPcopy Create free account
hub / github.com/PostHog/duckgres / TestDecodeBinaryCopy

Function TestDecodeBinaryCopy

server/conn_test.go:3110–3277  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

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
3166func TestDecodeBinaryCopy(t *testing.T) {
3167 tests := []struct {

Callers

nothing calls this directly

Calls 2

decodeBinaryCopyFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected