mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-25 02:08:44 +08:00
c27e00b45c
* Replace mongo package with monc & mon * Add terminal whitespace * format code
42 lines
869 B
Go
42 lines
869 B
Go
package generate
|
|
|
|
import (
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/zeromicro/go-zero/tools/goctl/util/pathx"
|
|
)
|
|
|
|
func TestTemplate(t *testing.T) {
|
|
tempDir := t.TempDir()
|
|
pathx.RegisterGoctlHome(tempDir)
|
|
t.Cleanup(func() {
|
|
pathx.RegisterGoctlHome("")
|
|
})
|
|
|
|
t.Run("Category", func(t *testing.T) {
|
|
assert.Equal(t, category, Category())
|
|
})
|
|
|
|
t.Run("Clean", func(t *testing.T) {
|
|
err := Clean()
|
|
assert.NoError(t, err)
|
|
})
|
|
|
|
t.Run("Templates", func(t *testing.T) {
|
|
err := Templates()
|
|
assert.NoError(t, err)
|
|
assert.True(t, pathx.FileExists(filepath.Join(tempDir, category, modelTemplateFile)))
|
|
})
|
|
|
|
t.Run("RevertTemplate", func(t *testing.T) {
|
|
assert.NoError(t, RevertTemplate(modelTemplateFile))
|
|
assert.Error(t, RevertTemplate("foo"))
|
|
})
|
|
|
|
t.Run("Update", func(t *testing.T) {
|
|
assert.NoError(t, Update())
|
|
})
|
|
}
|