chore: Embed unit test data (#1812)
* Embed unit test data * Add testdata Co-authored-by: anqiansong <anqiansong@bytedance.com>
This commit is contained in:
@@ -2,6 +2,7 @@ package gen
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
_ "embed"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
@@ -20,7 +21,8 @@ import (
|
||||
"github.com/zeromicro/go-zero/tools/goctl/util/pathx"
|
||||
)
|
||||
|
||||
var source = "CREATE TABLE `test_user` (\n `id` bigint NOT NULL AUTO_INCREMENT,\n `mobile` varchar(255) COLLATE utf8mb4_bin NOT NULL,\n `class` bigint NOT NULL,\n `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,\n `create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP,\n `update_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n PRIMARY KEY (`id`),\n UNIQUE KEY `mobile_unique` (`mobile`),\n UNIQUE KEY `class_name_unique` (`class`,`name`),\n KEY `create_index` (`create_time`),\n KEY `name_index` (`name`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;"
|
||||
//go:embed testdata/user.sql
|
||||
var source string
|
||||
|
||||
func TestCacheModel(t *testing.T) {
|
||||
logx.Disable()
|
||||
|
||||
14
tools/goctl/model/sql/gen/testdata/user.sql
vendored
Normal file
14
tools/goctl/model/sql/gen/testdata/user.sql
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
CREATE TABLE `test_user`
|
||||
(
|
||||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||||
`mobile` varchar(255) COLLATE utf8mb4_bin NOT NULL,
|
||||
`class` bigint NOT NULL,
|
||||
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
|
||||
`create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`update_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `mobile_unique` (`mobile`),
|
||||
UNIQUE KEY `class_name_unique` (`class`,`name`),
|
||||
KEY `create_index` (`create_time`),
|
||||
KEY `name_index` (`name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
|
||||
Reference in New Issue
Block a user