Files
sqlite3/ext/csv/schema_test.go

29 lines
788 B
Go
Raw Permalink Normal View History

2023-11-23 09:54:18 +00:00
package csv
import "testing"
func Test_getSchema(t *testing.T) {
2023-12-02 12:03:31 +00:00
t.Parallel()
2023-11-23 09:54:18 +00:00
tests := []struct {
header bool
columns int
row []string
want string
}{
2023-11-29 00:46:27 +00:00
{true, 2, nil, `CREATE TABLE x(c1 TEXT,c2 TEXT)`},
{false, 2, nil, `CREATE TABLE x(c1 TEXT,c2 TEXT)`},
{false, -1, []string{"abc", ""}, `CREATE TABLE x(c1 TEXT,c2 TEXT)`},
{true, 3, []string{"abc", ""}, `CREATE TABLE x("abc" TEXT,c2 TEXT,c3 TEXT)`},
{true, -1, []string{"abc", "def"}, `CREATE TABLE x("abc" TEXT,"def" TEXT)`},
{true, 1, []string{"abc", "def"}, `CREATE TABLE x("abc" TEXT)`},
2023-11-23 09:54:18 +00:00
}
for _, tt := range tests {
t.Run(tt.want, func(t *testing.T) {
if got := getSchema(tt.header, tt.columns, tt.row); got != tt.want {
t.Errorf("getSchema() = %v, want %v", got, tt.want)
}
})
}
}