github.com/jd-ly/cmd@v1.0.10/revel/new_test.go (about) 1 package main_test 2 3 import ( 4 "github.com/jd-ly/cmd/model" 5 "github.com/jd-ly/cmd/revel" 6 "github.com/stretchr/testify/assert" 7 "os" 8 "testing" 9 ) 10 11 // test the commands 12 func TestNew(t *testing.T) { 13 a := assert.New(t) 14 gopath := setup("revel-test-new", a) 15 16 t.Run("New", func(t *testing.T) { 17 a := assert.New(t) 18 c := newApp("new-test", model.NEW, nil, a) 19 a.Nil(main.Commands[model.NEW].RunWith(c), "New failed") 20 }) 21 t.Run("New-NotVendoredmode", func(t *testing.T) { 22 a := assert.New(t) 23 c := newApp("new-notvendored", model.NEW, nil, a) 24 c.New.NotVendored = true 25 a.Nil(main.Commands[model.NEW].RunWith(c), "New failed") 26 }) 27 t.Run("Path", func(t *testing.T) { 28 a := assert.New(t) 29 c := newApp("new/test/a", model.NEW, nil, a) 30 a.Nil(main.Commands[model.NEW].RunWith(c), "New path failed") 31 }) 32 t.Run("Path-Duplicate", func(t *testing.T) { 33 a := assert.New(t) 34 c := newApp("new/test/b", model.NEW, nil, a) 35 a.Nil(main.Commands[model.NEW].RunWith(c), "New path failed") 36 c = newApp("new/test/b", model.NEW, nil, a) 37 a.NotNil(main.Commands[model.NEW].RunWith(c), "Duplicate path Did Not failed") 38 }) 39 t.Run("Skeleton-Git", func(t *testing.T) { 40 a := assert.New(t) 41 c := newApp("new/test/c/1", model.NEW, nil, a) 42 c.New.SkeletonPath = "git://github.com/revel/skeletons:basicnsadnsak" 43 a.NotNil(main.Commands[model.NEW].RunWith(c), "Expected Failed to run with new") 44 // We need to pick a different path 45 c = newApp("new/test/c/2", model.NEW, nil, a) 46 c.New.SkeletonPath = "git://github.com/revel/skeletons:basic/bootstrap4" 47 a.Nil(main.Commands[model.NEW].RunWith(c), "Failed to run with new skeleton git") 48 }) 49 if !t.Failed() { 50 if err := os.RemoveAll(gopath); err != nil { 51 a.Fail("Failed to remove test path") 52 } 53 } 54 } 55