Break sanitize test into multiple checks

pgx-vs-pq
Jack Christensen 2013-05-07 08:19:12 -05:00
parent ec460173eb
commit e21955a1e4
1 changed files with 13 additions and 1 deletions

View File

@ -19,7 +19,19 @@ func TestQuoteString(t *testing.T) {
func TestSanitizeSql(t *testing.T) {
conn := getSharedConnection()
if conn.SanitizeSql("select $1", "Jack's") != "select 'Jack''s'" {
t.Error("Failed to sanitize string")
}
if conn.SanitizeSql("select $1", 42) != "select 42" {
t.Error("Failed to pass through integer")
}
if conn.SanitizeSql("select $1", 1.23) != "select 1.23" {
t.Error("Failed to pass through float")
}
if conn.SanitizeSql("select $1, $2, $3", "Jack's", 42, 1.23) != "select 'Jack''s', 42, 1.23" {
t.Error("Failed to sanitize sql")
t.Error("Failed to sanitize multiple params")
}
}