fix test error
This commit is contained in:
parent
01fa7fbbdb
commit
86e1d3defb
@ -7,6 +7,7 @@ ChangeLog
|
||||
0.2.1
|
||||
-----
|
||||
- Fix bug in windows.
|
||||
- Enhance PostgreSQL support.
|
||||
|
||||
0.2.0
|
||||
-----
|
||||
|
@ -1,3 +1,6 @@
|
||||
from typing import Type
|
||||
|
||||
from tortoise import Model
|
||||
from tortoise.backends.asyncpg.schema_generator import AsyncpgSchemaGenerator
|
||||
from tortoise.fields import Field
|
||||
|
||||
|
@ -73,7 +73,10 @@ def test_modify_column():
|
||||
|
||||
ret = Migrate.ddl.modify_column(User, User._meta.fields_map.get("is_active"))
|
||||
if isinstance(Migrate.ddl, MysqlDDL):
|
||||
assert ret == "ALTER TABLE `user` MODIFY COLUMN `is_active` BOOL NOT NULL"
|
||||
assert (
|
||||
ret
|
||||
== "ALTER TABLE `user` MODIFY COLUMN `is_active` BOOL NOT NULL COMMENT 'Is Active' DEFAULT 1"
|
||||
)
|
||||
elif isinstance(Migrate.ddl, PostgresDDL):
|
||||
assert ret == 'ALTER TABLE "user" ALTER COLUMN "is_active" TYPE BOOL'
|
||||
else:
|
||||
@ -88,7 +91,7 @@ def test_alter_column_default():
|
||||
if isinstance(Migrate.ddl, PostgresDDL):
|
||||
assert ret == 'ALTER TABLE "category" ALTER COLUMN "name" DROP DEFAULT'
|
||||
else:
|
||||
assert ret == None
|
||||
assert ret is None
|
||||
|
||||
ret = Migrate.ddl.alter_column_default(Category, Category._meta.fields_map.get("created_at"))
|
||||
if isinstance(Migrate.ddl, PostgresDDL):
|
||||
@ -96,13 +99,13 @@ def test_alter_column_default():
|
||||
ret == 'ALTER TABLE "category" ALTER COLUMN "created_at" SET DEFAULT CURRENT_TIMESTAMP'
|
||||
)
|
||||
else:
|
||||
assert ret == None
|
||||
assert ret is None
|
||||
|
||||
ret = Migrate.ddl.alter_column_default(User, User._meta.fields_map.get("avatar"))
|
||||
if isinstance(Migrate.ddl, PostgresDDL):
|
||||
assert ret == 'ALTER TABLE "user" ALTER COLUMN "avatar" SET DEFAULT \'\''
|
||||
else:
|
||||
assert ret == None
|
||||
assert ret is None
|
||||
|
||||
|
||||
def test_alter_column_null():
|
||||
@ -110,7 +113,7 @@ def test_alter_column_null():
|
||||
if isinstance(Migrate.ddl, PostgresDDL):
|
||||
assert ret == 'ALTER TABLE "category" ALTER COLUMN "name" SET NOT NULL'
|
||||
else:
|
||||
assert ret == None
|
||||
assert ret is None
|
||||
|
||||
|
||||
def test_set_comment():
|
||||
@ -118,13 +121,13 @@ def test_set_comment():
|
||||
if isinstance(Migrate.ddl, PostgresDDL):
|
||||
assert ret == 'COMMENT ON COLUMN "category"."name" IS NULL'
|
||||
else:
|
||||
assert ret == None
|
||||
assert ret is None
|
||||
|
||||
ret = Migrate.ddl.set_comment(Category, Category._meta.fields_map.get("user"))
|
||||
if isinstance(Migrate.ddl, PostgresDDL):
|
||||
assert ret == 'COMMENT ON COLUMN "category"."user" IS \'User\''
|
||||
else:
|
||||
assert ret == None
|
||||
assert ret is None
|
||||
|
||||
|
||||
def test_drop_column():
|
||||
|
Loading…
x
Reference in New Issue
Block a user