github.com/loggregator/cli@v6.33.1-0.20180224010324-82334f081791+incompatible/cf/commands/logout_test.go (about) 1 package commands_test 2 3 import ( 4 "code.cloudfoundry.org/cli/cf/commandregistry" 5 "code.cloudfoundry.org/cli/cf/configuration/coreconfig" 6 "code.cloudfoundry.org/cli/cf/models" 7 testcmd "code.cloudfoundry.org/cli/util/testhelpers/commands" 8 testconfig "code.cloudfoundry.org/cli/util/testhelpers/configuration" 9 testterm "code.cloudfoundry.org/cli/util/testhelpers/terminal" 10 . "github.com/onsi/ginkgo" 11 . "github.com/onsi/gomega" 12 ) 13 14 var _ = Describe("logout command", func() { 15 16 var ( 17 config coreconfig.Repository 18 ui *testterm.FakeUI 19 deps commandregistry.Dependency 20 ) 21 22 updateCommandDependency := func(pluginCall bool) { 23 deps.UI = ui 24 deps.Config = config 25 commandregistry.Commands.SetCommand(commandregistry.Commands.FindCommand("logout").SetDependency(deps, pluginCall)) 26 } 27 28 BeforeEach(func() { 29 org := models.OrganizationFields{} 30 org.Name = "MyOrg" 31 32 space := models.SpaceFields{} 33 space.Name = "MySpace" 34 35 config = testconfig.NewRepository() 36 config.SetAccessToken("MyAccessToken") 37 config.SetOrganizationFields(org) 38 config.SetSpaceFields(space) 39 ui = &testterm.FakeUI{} 40 41 testcmd.RunCLICommand("logout", []string{}, nil, updateCommandDependency, false, ui) 42 }) 43 44 It("clears access token from the config", func() { 45 Expect(config.AccessToken()).To(Equal("")) 46 }) 47 48 It("clears organization fields from the config", func() { 49 Expect(config.OrganizationFields()).To(Equal(models.OrganizationFields{})) 50 }) 51 52 It("clears space fields from the config", func() { 53 Expect(config.SpaceFields()).To(Equal(models.SpaceFields{})) 54 }) 55 })