github.com/mlmmr/revel-cmd@v0.21.2-0.20191112133115-68d8795776dd/revel/version_test.go (about) 1 package main_test 2 3 import ( 4 "github.com/mlmmr/revel-cmd/model" 5 "github.com/mlmmr/revel-cmd/revel" 6 "github.com/stretchr/testify/assert" 7 "os" 8 "path/filepath" 9 "testing" 10 ) 11 12 // test the commands 13 func TestVersion(t *testing.T) { 14 a := assert.New(t) 15 gopath := setup("revel-test-version", a) 16 17 t.Run("Version", func(t *testing.T) { 18 a := assert.New(t) 19 c := newApp("version-test", model.NEW, nil, a) 20 a.Nil(main.Commands[model.NEW].RunWith(c), "Check new") 21 c.Build.ImportPath = c.ImportPath 22 c.Build.TargetPath = filepath.Join(gopath, "build-test", "target") 23 a.Nil(main.Commands[model.BUILD].RunWith(c), "Failed to run build") 24 c.Index = model.VERSION 25 c.Version.ImportPath = c.ImportPath 26 a.Nil(main.Commands[model.VERSION].RunWith(c), "Failed to run version-test") 27 }) 28 t.Run("Version-Nobuild", func(t *testing.T) { 29 a := assert.New(t) 30 c := newApp("version-test2", model.NEW, nil, a) 31 a.Nil(main.Commands[model.NEW].RunWith(c), "Check new") 32 c.Index = model.VERSION 33 c.Version.ImportPath = c.ImportPath 34 a.Nil(main.Commands[model.VERSION].RunWith(c), "Failed to run version-test") 35 }) 36 if !t.Failed() { 37 if err := os.RemoveAll(gopath); err != nil { 38 a.Fail("Failed to remove test path") 39 } 40 } 41 }