github.com/tobgu/qframe@v0.4.0/internal/io/sql/stmt_test.go (about) 1 package sql 2 3 import ( 4 "testing" 5 ) 6 7 func TestInsert(t *testing.T) { 8 // Unescaped 9 query := Insert([]string{"COL1", "COL2"}, SQLConfig{Table: "test"}) 10 expected := `INSERT INTO test (COL1,COL2) VALUES (?,?);` 11 assertEqual(t, expected, query) 12 13 // Double quote escaped 14 query = Insert([]string{"COL1", "COL2"}, SQLConfig{ 15 Table: "test", EscapeChar: '"'}) 16 expected = "INSERT INTO \"test\" (\"COL1\",\"COL2\") VALUES (?,?);" 17 assertEqual(t, expected, query) 18 19 // Backtick escaped 20 query = Insert([]string{"COL1", "COL2"}, SQLConfig{ 21 Table: "test", EscapeChar: '`'}) 22 expected = "INSERT INTO `test` (`COL1`,`COL2`) VALUES (?,?);" 23 assertEqual(t, expected, query) 24 }