Feature mongo gen (#546)

* add feature: mongo code generation

* upgrade version

* update doc

* format code

* update update.tpl of mysql
This commit is contained in:
anqiansong
2021-03-12 17:49:28 +08:00
committed by GitHub
parent c954568b61
commit dda7666097
10 changed files with 569 additions and 3 deletions

View File

@@ -0,0 +1,34 @@
package generate
import (
"io/ioutil"
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
"github.com/tal-tech/go-zero/tools/goctl/config"
)
var testTypes = `
type User struct{}
type Class struct{}
`
func TestDo(t *testing.T) {
cfg, err := config.NewConfig(config.DefaultFormat)
assert.Nil(t, err)
tempDir := t.TempDir()
typesfile := filepath.Join(tempDir, "types.go")
err = ioutil.WriteFile(typesfile, []byte(testTypes), 0666)
assert.Nil(t, err)
err = Do(&Context{
Types: []string{"User", "Class"},
Cache: false,
Output: tempDir,
Cfg: cfg,
})
assert.Nil(t, err)
}