github.com/ncruces/go-sqlite3@v0.15.1-0.20240520133447-53eef1510ff0/ext/csv/schema_test.go (about) 1 package csv 2 3 import "testing" 4 5 func Test_getSchema(t *testing.T) { 6 t.Parallel() 7 8 tests := []struct { 9 header bool 10 columns int 11 row []string 12 want string 13 }{ 14 {true, 2, nil, `CREATE TABLE x(c1 TEXT,c2 TEXT)`}, 15 {false, 2, nil, `CREATE TABLE x(c1 TEXT,c2 TEXT)`}, 16 {false, -1, []string{"abc", ""}, `CREATE TABLE x(c1 TEXT,c2 TEXT)`}, 17 {true, 3, []string{"abc", ""}, `CREATE TABLE x("abc" TEXT,c2 TEXT,c3 TEXT)`}, 18 {true, -1, []string{"abc", "def"}, `CREATE TABLE x("abc" TEXT,"def" TEXT)`}, 19 {true, 1, []string{"abc", "def"}, `CREATE TABLE x("abc" TEXT)`}, 20 } 21 for _, tt := range tests { 22 t.Run(tt.want, func(t *testing.T) { 23 if got := getSchema(tt.header, tt.columns, tt.row); got != tt.want { 24 t.Errorf("getSchema() = %v, want %v", got, tt.want) 25 } 26 }) 27 } 28 }