bob/rename_test.go

29 lines
626 B
Go
Raw Normal View History

2021-07-24 18:35:12 +00:00
package bob_test
import (
"testing"
"github.com/aldy505/bob"
)
func TestRename(t *testing.T) {
2021-07-31 04:48:40 +00:00
t.Run("should be able to create rename query", func(t *testing.T) {
2021-07-24 18:35:12 +00:00
sql, _, err := bob.RenameTable("users", "teachers").ToSql()
if err != nil {
t.Error(err)
}
result := "RENAME TABLE \"users\" TO \"teachers\";"
if sql != result {
t.Error("sql is not the same as result: ", sql)
}
})
t.Run("should expect an error for no table name", func(t *testing.T) {
_, _, err := bob.RenameTable("", "").ToSql()
if err == nil && err.Error() != "rename statement must specify a table" {
t.Error(err)
}
})
2021-07-31 04:48:40 +00:00
}