mirror of
https://github.com/ent/ent.git
synced 2026-05-28 09:49:08 +03:00
dialect/sql/schema: add mysql tests for checks annotation
This commit is contained in:
committed by
Ariel Mashraki
parent
42a2c67cc4
commit
1d661deb50
@@ -68,13 +68,17 @@ func TestMySQL_Create(t *testing.T) {
|
||||
Charset: "utf8",
|
||||
Collation: "utf8_general_ci",
|
||||
Options: "ENGINE = INNODB",
|
||||
Check: "price > 0",
|
||||
Checks: map[string]string{
|
||||
"valid_name": "name <> ''",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
before: func(mock mysqlMock) {
|
||||
mock.start("5.7.8")
|
||||
mock.tableExists("users", false)
|
||||
mock.ExpectExec(escape("CREATE TABLE IF NOT EXISTS `users`(`id` bigint AUTO_INCREMENT NOT NULL, `name` varchar(255) NULL, `age` bigint NOT NULL, `doc` json NULL, `enums` enum('a', 'b') NOT NULL, `uuid` char(36) binary NULL, `ts` timestamp NULL, `ts_default` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `datetime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `decimal` decimal(6,2) NOT NULL, `unsigned decimal` decimal(6,2) unsigned NOT NULL, PRIMARY KEY(`id`)) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = INNODB")).
|
||||
mock.ExpectExec(escape("CREATE TABLE IF NOT EXISTS `users`(`id` bigint AUTO_INCREMENT NOT NULL, `name` varchar(255) NULL, `age` bigint NOT NULL, `doc` json NULL, `enums` enum('a', 'b') NOT NULL, `uuid` char(36) binary NULL, `ts` timestamp NULL, `ts_default` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `datetime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `decimal` decimal(6,2) NOT NULL, `unsigned decimal` decimal(6,2) unsigned NOT NULL, PRIMARY KEY(`id`), CHECK (price > 0), CONSTRAINT `valid_name` CHECK (name <> '')) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = INNODB")).
|
||||
WillReturnResult(sqlmock.NewResult(0, 1))
|
||||
mock.ExpectCommit()
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user