MCPcopy
hub / github.com/zeromicro/go-zero / TestParseCreateTable

Function TestParseCreateTable

tools/goctl/model/sql/parser/parser_test.go:37–59  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

35var user string
36
37func TestParseCreateTable(t *testing.T) {
38 sqlFile := filepath.Join(pathx.MustTempDir(), "tmp.sql")
39 err := os.WriteFile(sqlFile, []byte(user), 0o777)
40 assert.Nil(t, err)
41
42 tables, err := Parse(sqlFile, "go_zero", false)
43 assert.Equal(t, 1, len(tables))
44 table := tables[0]
45 assert.Nil(t, err)
46 assert.Equal(t, "test_user", table.Name.Source())
47 assert.Equal(t, "id", table.PrimaryKey.Name.Source())
48 assert.Equal(t, true, table.ContainsTime())
49 assert.Equal(t, 2, len(table.UniqueIndex))
50 assert.True(t, func() bool {
51 for _, e := range table.Fields {
52 if e.Comment != util.TrimNewLine(e.Comment) {
53 return false
54 }
55 }
56
57 return true
58 }())
59}
60
61func TestConvertColumn(t *testing.T) {
62 t.Run("missingPrimaryKey", func(t *testing.T) {

Callers

nothing calls this directly

Calls 8

MustTempDirFunction · 0.92
TrimNewLineFunction · 0.92
JoinMethod · 0.80
SourceMethod · 0.80
ContainsTimeMethod · 0.80
TrueMethod · 0.80
ParseFunction · 0.70
EqualMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…