github.com/jasonkeene/cli@v6.14.1-0.20160816203908-ca5715166dfb+incompatible/cf/commands/version_test.go (about)

     1  package commands_test
     2  
     3  import (
     4  	"github.com/cloudfoundry/cli/cf/commandregistry"
     5  	"github.com/cloudfoundry/cli/cf/commands"
     6  	"github.com/cloudfoundry/cli/cf/flags"
     7  
     8  	testterm "github.com/cloudfoundry/cli/testhelpers/terminal"
     9  
    10  	"github.com/cloudfoundry/cli/cf"
    11  	. "github.com/onsi/ginkgo"
    12  	. "github.com/onsi/gomega"
    13  )
    14  
    15  var _ = Describe("Version", func() {
    16  	var (
    17  		ui  *testterm.FakeUI
    18  		cmd commandregistry.Command
    19  	)
    20  
    21  	BeforeEach(func() {
    22  		ui = &testterm.FakeUI{}
    23  
    24  		deps := commandregistry.Dependency{
    25  			UI: ui,
    26  		}
    27  
    28  		cmd = &commands.Version{}
    29  		cmd.SetDependency(deps, false)
    30  	})
    31  
    32  	Describe("Execute", func() {
    33  		var flagContext flags.FlagContext
    34  
    35  		BeforeEach(func() {
    36  			cf.Version = "5.0.0"
    37  			cf.Name = "my-special-cf"
    38  			cf.BuiltOnDate = "2016-02-29"
    39  		})
    40  
    41  		It("prints the version", func() {
    42  			cmd.Execute(flagContext)
    43  
    44  			Expect(ui.Outputs()).To(Equal([]string{
    45  				"my-special-cf version 5.0.0-2016-02-29",
    46  			}))
    47  		})
    48  	})
    49  })