github.com/ablease/cli@v6.37.1-0.20180613014814-3adbb7d7fb19+incompatible/command/v2/logout_command_test.go (about)

     1  package v2_test
     2  
     3  import (
     4  	"code.cloudfoundry.org/cli/command/commandfakes"
     5  	. "code.cloudfoundry.org/cli/command/v2"
     6  	"code.cloudfoundry.org/cli/util/configv3"
     7  	"code.cloudfoundry.org/cli/util/ui"
     8  	. "github.com/onsi/ginkgo"
     9  	. "github.com/onsi/gomega"
    10  	. "github.com/onsi/gomega/gbytes"
    11  )
    12  
    13  var _ = Describe("logout command", func() {
    14  	var (
    15  		cmd        LogoutCommand
    16  		testUI     *ui.UI
    17  		fakeConfig *commandfakes.FakeConfig
    18  		executeErr error
    19  	)
    20  
    21  	BeforeEach(func() {
    22  		testUI = ui.NewTestUI(nil, NewBuffer(), NewBuffer())
    23  		fakeConfig = new(commandfakes.FakeConfig)
    24  		cmd = LogoutCommand{
    25  			UI:     testUI,
    26  			Config: fakeConfig,
    27  		}
    28  		fakeConfig.CurrentUserReturns(
    29  			configv3.User{
    30  				Name: "some-user",
    31  			},
    32  			nil)
    33  	})
    34  
    35  	JustBeforeEach(func() {
    36  		executeErr = cmd.Execute(nil)
    37  	})
    38  
    39  	It("outputs logging out display message", func() {
    40  		Expect(executeErr).ToNot(HaveOccurred())
    41  
    42  		Expect(fakeConfig.UnsetUserInformationCallCount()).To(Equal(1))
    43  		Expect(testUI.Out).To(Say("Logging out some-user..."))
    44  		Expect(testUI.Out).To(Say("OK"))
    45  	})
    46  })