-
-
Notifications
You must be signed in to change notification settings - Fork 955
Expand file tree
/
Copy pathdeprecated_test.go
More file actions
53 lines (46 loc) · 1.36 KB
/
deprecated_test.go
File metadata and controls
53 lines (46 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package pq
import "testing"
func TestCopyInStmt(t *testing.T) {
tests := []struct {
inTable string
inCols []string
want string
}{
{`table name`, nil, `COPY "table name" FROM STDIN`},
{"table name", []string{"column 1", "column 2"}, `COPY "table name" ("column 1", "column 2") FROM STDIN`},
{`table " name """`, []string{`co"lumn""`}, `COPY "table "" name """"""" ("co""lumn""""") FROM STDIN`},
}
for _, tt := range tests {
t.Run("", func(t *testing.T) {
t.Parallel()
have := CopyIn(tt.inTable, tt.inCols...)
if have != tt.want {
t.Fatalf("\nhave: %q\nwant: %q", have, tt.want)
}
})
}
}
func TestCopyInSchemaStmt(t *testing.T) {
tests := []struct {
inSchema string
inTable string
inCols []string
want string
}{
{"schema name", "table name", nil,
`COPY "schema name"."table name" FROM STDIN`},
{"schema name", "table name", []string{"column 1", "column 2"},
`COPY "schema name"."table name" ("column 1", "column 2") FROM STDIN`},
{`schema " name """`, `table " name """`, []string{`co"lumn""`},
`COPY "schema "" name """""""."table "" name """"""" ("co""lumn""""") FROM STDIN`},
}
for _, tt := range tests {
t.Run("", func(t *testing.T) {
t.Parallel()
have := CopyInSchema(tt.inSchema, tt.inTable, tt.inCols...)
if have != tt.want {
t.Fatalf("\nhave: %q\nwant: %q", have, tt.want)
}
})
}
}