Add a little example test to the generator.

master
Zed A. Shaw 3 weeks ago
parent 7f304f9950
commit a45371e48f
  1. 8
      tools/cmd/fgen/main.go
  2. 14
      tools/cmd/fgen/templates/tests/example_test.go

@ -46,6 +46,7 @@ func main() {
feature_dir := filepath.Join("features", config.Name) feature_dir := filepath.Join("features", config.Name)
view_dir := filepath.Join("views", config.Name) view_dir := filepath.Join("views", config.Name)
tests_dir := filepath.Join("tests", config.Name)
err := os.MkdirAll(feature_dir, 0755) err := os.MkdirAll(feature_dir, 0755)
if err != nil { panic(err) } if err != nil { panic(err) }
@ -53,6 +54,9 @@ func main() {
err = os.MkdirAll(view_dir, 0755) err = os.MkdirAll(view_dir, 0755)
if err != nil { panic(err) } if err != nil { panic(err) }
err = os.MkdirAll(tests_dir, 0755)
if err != nil { panic(err) }
err = fs.WalkDir(templates, "templates", err = fs.WalkDir(templates, "templates",
func(path string, d fs.DirEntry, err error) error { func(path string, d fs.DirEntry, err error) error {
if err != nil { return err } if err != nil { return err }
@ -68,6 +72,10 @@ func main() {
out_path := filepath.Join("features", config.Name, target) out_path := filepath.Join("features", config.Name, target)
err := WriteTemplate(config, path, out_path) err := WriteTemplate(config, path, out_path)
if err != nil { panic(err) } if err != nil { panic(err) }
case strings.HasPrefix(path, "templates/tests"):
out_path := filepath.Join("tests", config.Name, target)
err := WriteTemplate(config, path, out_path)
if err != nil { panic(err) }
} }
} }

@ -0,0 +1,14 @@
package tests
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestLogin(t *testing.T) {
assert.Equal(true, false)
}
func TestMain(m *testing.M) {
m.Run()
}
Loading…
Cancel
Save