database-anonymizer/database/database_test.go
Simon Vieille 6754905f24
Some checks failed
ci/woodpecker/push/test Pipeline failed
ci/woodpecker/push/build unknown status
add column escaper function
2024-07-18 17:03:32 +02:00

35 lines
814 B
Go

package database
import (
"testing"
)
func TestEscapeTable(t *testing.T) {
if EscapeTable("mysql", "foo") != "`foo`" {
t.Fatalf("TestEscapeTable: mysql check failed")
}
if EscapeTable("postgres", "foo") != "\"foo\"" {
t.Fatalf("TestEscapeTable: postgres check failed")
}
}
func TestEscapeColumn(t *testing.T) {
if EscapeColumn("mysql", "foo") != "`foo`" {
t.Fatalf("TestEscapeColumn: mysql check failed")
}
if EscapeTable("postgres", "foo") != "\"foo\"" {
t.Fatalf("TestEscapeColumn: postgres check failed")
}
}
func TestGetNamedParameter(t *testing.T) {
if GetNamedParameter("mysql", "foo", 1) != "foo=?" {
t.Fatalf("TestGetNamedParameter: mysql check failed")
}
if GetNamedParameter("postgres", "foo", 1) != "foo=$1" {
t.Fatalf("TestGetNamedParameter: postgres check failed")
}
}