Expect(Config.AccessToken()).To(Equal("my_access_token")) Expect(Config.RefreshToken()).To(Equal("my_refresh_token")) testassert.SliceContains(ui.Outputs, testassert.Lines{ {"Failed"}, }) }) }) Context("when the user is already logged in and the config is fully populated", func() { BeforeEach(func() { Config = testconfig.NewRepositoryWithDefaults() Config.SetApiEndpoint("api.example.com") Config.SetAccessToken("my_access_token") Config.SetRefreshToken("my_refesh_token") authRepo.Config = Config }) Describe("and a new login fails to set api endpoint", func() { BeforeEach(func() { endpointRepo.UpdateEndpointError = errors.NewErrorWithMessage("API endpoint not found") Flags = []string{"-a", "api.nonexistent.com"} l := NewLogin(ui, Config, authRepo, endpointRepo, orgRepo, spaceRepo) testcmd.RunCommand(l, testcmd.NewContext("login", Flags), nil) }) It("clears the entire config", func() { Expect(Config.ApiEndpoint()).To(BeEmpty()) Expect(Config.AccessToken()).To(BeEmpty()) Expect(Config.RefreshToken()).To(BeEmpty())