github.com/franc20/ayesa_sap@v7.0.0-beta.28.0.20200124003224-302d4d52fa6c+incompatible/command/v6/logout_command_test.go (about) 1 package v6_test 2 3 import ( 4 "code.cloudfoundry.org/cli/command/commandfakes" 5 . "code.cloudfoundry.org/cli/command/v6" 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 })