feat: Replace mongo package with monc & mon (#2002)
* Replace mongo package with monc & mon * Add terminal whitespace * format code
This commit is contained in:
@@ -16,20 +16,53 @@ var testTypes = `
|
||||
`
|
||||
|
||||
func TestDo(t *testing.T) {
|
||||
cfg, err := config.NewConfig(config.DefaultFormat)
|
||||
assert.Nil(t, err)
|
||||
t.Run("should generate model", func(t *testing.T) {
|
||||
cfg, err := config.NewConfig(config.DefaultFormat)
|
||||
assert.Nil(t, err)
|
||||
|
||||
tempDir := pathx.MustTempDir()
|
||||
typesfile := filepath.Join(tempDir, "types.go")
|
||||
err = ioutil.WriteFile(typesfile, []byte(testTypes), 0o666)
|
||||
assert.Nil(t, err)
|
||||
tempDir := pathx.MustTempDir()
|
||||
typesfile := filepath.Join(tempDir, "types.go")
|
||||
err = ioutil.WriteFile(typesfile, []byte(testTypes), 0o666)
|
||||
assert.Nil(t, err)
|
||||
|
||||
err = Do(&Context{
|
||||
Types: []string{"User", "Class"},
|
||||
Cache: false,
|
||||
Output: tempDir,
|
||||
Cfg: cfg,
|
||||
err = Do(&Context{
|
||||
Types: []string{"User", "Class"},
|
||||
Cache: false,
|
||||
Output: tempDir,
|
||||
Cfg: cfg,
|
||||
})
|
||||
|
||||
assert.Nil(t, err)
|
||||
})
|
||||
|
||||
assert.Nil(t, err)
|
||||
t.Run("missing config", func(t *testing.T) {
|
||||
tempDir := t.TempDir()
|
||||
typesfile := filepath.Join(tempDir, "types.go")
|
||||
err := ioutil.WriteFile(typesfile, []byte(testTypes), 0o666)
|
||||
assert.Nil(t, err)
|
||||
|
||||
err = Do(&Context{
|
||||
Types: []string{"User", "Class"},
|
||||
Cache: false,
|
||||
Output: tempDir,
|
||||
Cfg: nil,
|
||||
})
|
||||
assert.Error(t, err)
|
||||
})
|
||||
|
||||
t.Run("invalid config", func(t *testing.T) {
|
||||
cfg := &config.Config{NamingFormat: "foo"}
|
||||
tempDir := t.TempDir()
|
||||
typesfile := filepath.Join(tempDir, "types.go")
|
||||
err := ioutil.WriteFile(typesfile, []byte(testTypes), 0o666)
|
||||
assert.Nil(t, err)
|
||||
|
||||
err = Do(&Context{
|
||||
Types: []string{"User", "Class"},
|
||||
Cache: false,
|
||||
Output: tempDir,
|
||||
Cfg: cfg,
|
||||
})
|
||||
assert.Error(t, err)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user