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