mirror of https://github.com/aldy505/bob.git
test: simplify test
This commit is contained in:
parent
4603861691
commit
43eb8f4234
|
@ -40,16 +40,13 @@ func TestCreate(t *testing.T) {
|
||||||
t.Run("should return correct sql with extras", func(t *testing.T) {
|
t.Run("should return correct sql with extras", func(t *testing.T) {
|
||||||
sql, _, err := bob.CreateTable("users").
|
sql, _, err := bob.CreateTable("users").
|
||||||
UUIDColumn("id", "PRIMARY KEY").
|
UUIDColumn("id", "PRIMARY KEY").
|
||||||
StringColumn("name").
|
|
||||||
StringColumn("email", "NOT NULL", "UNIQUE").
|
StringColumn("email", "NOT NULL", "UNIQUE").
|
||||||
TextColumn("password").
|
|
||||||
DateTimeColumn("date").
|
|
||||||
ToSql()
|
ToSql()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err.Error())
|
t.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
result := "CREATE TABLE \"users\" (\"id\" UUID PRIMARY KEY, \"name\" VARCHAR(255), \"email\" VARCHAR(255) NOT NULL UNIQUE, \"password\" TEXT, \"date\" DATETIME);"
|
result := "CREATE TABLE \"users\" (\"id\" UUID PRIMARY KEY, \"email\" VARCHAR(255) NOT NULL UNIQUE);"
|
||||||
if sql != result {
|
if sql != result {
|
||||||
t.Fatal("sql is not equal to result:", sql)
|
t.Fatal("sql is not equal to result:", sql)
|
||||||
}
|
}
|
||||||
|
@ -60,13 +57,11 @@ func TestCreate(t *testing.T) {
|
||||||
CreateTable("users").
|
CreateTable("users").
|
||||||
WithSchema("private").
|
WithSchema("private").
|
||||||
StringColumn("name").
|
StringColumn("name").
|
||||||
TextColumn("password").
|
|
||||||
DateColumn("date").
|
|
||||||
ToSql()
|
ToSql()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err.Error())
|
t.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
result := "CREATE TABLE \"private\".\"users\" (\"name\" VARCHAR(255), \"password\" TEXT, \"date\" DATE);"
|
result := "CREATE TABLE \"private\".\"users\" (\"name\" VARCHAR(255));"
|
||||||
if sql != result {
|
if sql != result {
|
||||||
t.Fatal("sql is not equal to result:", sql)
|
t.Fatal("sql is not equal to result:", sql)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue