add tests

This commit is contained in:
Simon Vieille 2024-03-20 12:26:46 +01:00
commit 2081937a24
Signed by untrusted user: deblan
GPG key ID: 579388D585F70417
2 changed files with 118 additions and 0 deletions

30
app/app_test.go Normal file
View file

@ -0,0 +1,30 @@
package app
import (
_ "github.com/go-sql-driver/mysql"
"gitnet.fr/deblan/database-anonymizer/config"
"gitnet.fr/deblan/database-anonymizer/faker"
"testing"
)
func GetApp() App {
return App{
FakeManager: faker.NewFakeManager(),
DbConfig: config.DatabaseConfig{Type: "mysql", Dsn: "mysql://foo:bar@tests"},
}
}
func TestAppCreateSelectQuery(t *testing.T) {
c := config.SchemaConfigAction{Table: "foo"}
app := GetApp()
if app.CreateSelectQuery(c) != "SELECT * FROM `foo`" {
t.Fatalf("TestAppCreateSelectQuery: empty configured query check failed")
}
c = config.SchemaConfigAction{Table: "foo", Query: "query"}
if app.CreateSelectQuery(c) != "query" {
t.Fatalf("TestAppCreateSelectQuery: configured query check failed")
}
}