github.com/terhitormanen/cmd@v1.1.4/revel/package_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 TestPackage(t *testing.T) {
    14  	a := assert.New(t)
    15  	gopath := setup("revel-test-package", a)
    16  
    17  	t.Run("Package", func(t *testing.T) {
    18  		a := assert.New(t)
    19  		c := newApp("package-test", model.NEW, nil, a)
    20  		a.Nil(main.Commands[model.NEW].RunWith(c), "failed to run new")
    21  		c.Index = model.PACKAGE
    22  		c.Package.ImportPath = c.ImportPath
    23  		a.Nil(main.Commands[model.PACKAGE].RunWith(c), "Failed to run package-test")
    24  	})
    25  
    26  	if !t.Failed() {
    27  		if err := os.RemoveAll(gopath); err != nil {
    28  			a.Fail("Failed to remove test path")
    29  		}
    30  	}
    31  }