github.com/jenspinney/cli@v6.42.1-0.20190207184520-7450c600020e+incompatible/command/common/version_command_test.go (about)

     1  package common_test
     2  
     3  import (
     4  	"code.cloudfoundry.org/cli/command/commandfakes"
     5  	. "code.cloudfoundry.org/cli/command/common"
     6  	"code.cloudfoundry.org/cli/util/ui"
     7  
     8  	. "github.com/onsi/ginkgo"
     9  	. "github.com/onsi/gomega"
    10  	. "github.com/onsi/gomega/gbytes"
    11  )
    12  
    13  var _ = Describe("Version Command", func() {
    14  	var (
    15  		cmd        VersionCommand
    16  		testUI     *ui.UI
    17  		fakeConfig *commandfakes.FakeConfig
    18  		err        error
    19  	)
    20  
    21  	BeforeEach(func() {
    22  		testUI = ui.NewTestUI(nil, NewBuffer(), NewBuffer())
    23  		fakeConfig = new(commandfakes.FakeConfig)
    24  		fakeConfig.BinaryNameReturns("faceman")
    25  		fakeConfig.BinaryVersionReturns("0.0.0-invalid-version")
    26  
    27  		cmd = VersionCommand{
    28  			UI:     testUI,
    29  			Config: fakeConfig,
    30  		}
    31  	})
    32  
    33  	It("displays correct version", func() {
    34  		err = cmd.Execute(nil)
    35  		Expect(err).ToNot(HaveOccurred())
    36  		Expect(testUI.Out).To(Say("faceman version 0.0.0-invalid-version"))
    37  	})
    38  })