Add strict flag (#2248)

Co-authored-by: Kevin Wan <wanjunfeng@gmail.com>
This commit is contained in:
anqiansong
2022-08-28 18:55:52 +08:00
committed by GitHub
parent a1466e1707
commit f70805ee60
9 changed files with 126 additions and 57 deletions

View File

@@ -7,6 +7,7 @@ import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/zeromicro/go-zero/tools/goctl/model/sql/model"
"github.com/zeromicro/go-zero/tools/goctl/model/sql/util"
"github.com/zeromicro/go-zero/tools/goctl/util/pathx"
@@ -17,7 +18,7 @@ func TestParsePlainText(t *testing.T) {
err := ioutil.WriteFile(sqlFile, []byte("plain text"), 0o777)
assert.Nil(t, err)
_, err = Parse(sqlFile, "go_zero")
_, err = Parse(sqlFile, "go_zero", false)
assert.NotNil(t, err)
}
@@ -26,7 +27,7 @@ func TestParseSelect(t *testing.T) {
err := ioutil.WriteFile(sqlFile, []byte("select * from user"), 0o777)
assert.Nil(t, err)
tables, err := Parse(sqlFile, "go_zero")
tables, err := Parse(sqlFile, "go_zero", false)
assert.Nil(t, err)
assert.Equal(t, 0, len(tables))
}
@@ -39,7 +40,7 @@ func TestParseCreateTable(t *testing.T) {
err := ioutil.WriteFile(sqlFile, []byte(user), 0o777)
assert.Nil(t, err)
tables, err := Parse(sqlFile, "go_zero")
tables, err := Parse(sqlFile, "go_zero", false)
assert.Equal(t, 1, len(tables))
table := tables[0]
assert.Nil(t, err)