fix: model generation bug on with cache (#1743)

* fix: model generation bug on with cache

* chore: refine template

* chore: fix test failure
This commit is contained in:
Kevin Wan
2022-04-02 15:36:06 +08:00
committed by GitHub
parent 83cacf51b7
commit dfd58c213c
3 changed files with 18 additions and 7 deletions

View File

@@ -145,7 +145,10 @@ func Test_genPublicModel(t *testing.T) {
tables, err := parser.Parse(modelFilename, "")
require.Equal(t, 1, len(tables))
code, err := g.genModelCustom(*tables[0])
code, err := g.genModelCustom(*tables[0], false)
assert.NoError(t, err)
assert.Equal(t, "package model\n\ntype TestUserModel interface {\n\ttestUserModel\n}\n", code)
assert.True(t, strings.Contains(code, "package model"))
assert.True(t, strings.Contains(code, "TestUserModel interface {\n\t\ttestUserModel\n\t}\n"))
assert.True(t, strings.Contains(code, "customTestUserModel struct {\n\t\t*defaultTestUserModel\n\t}\n"))
assert.True(t, strings.Contains(code, "func NewTestUserModel(conn sqlx.SqlConn) TestUserModel {"))
}