当前位置: 首页>>代码示例>>Golang>>正文


Golang FakeConfigRepository.Delete方法代码示例

本文整理汇总了Golang中testhelpers/configuration.FakeConfigRepository.Delete方法的典型用法代码示例。如果您正苦于以下问题:Golang FakeConfigRepository.Delete方法的具体用法?Golang FakeConfigRepository.Delete怎么用?Golang FakeConfigRepository.Delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在testhelpers/configuration.FakeConfigRepository的用法示例。


在下文中一共展示了FakeConfigRepository.Delete方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: TestUpdateEndpointWhenUrlIsValidHttpsInfoEndpoint

func TestUpdateEndpointWhenUrlIsValidHttpsInfoEndpoint(t *testing.T) {
	configRepo := testconfig.FakeConfigRepository{}
	configRepo.Delete()
	configRepo.Login()

	ts, repo := createEndpointRepoForUpdate(configRepo, validApiInfoEndpoint)
	defer ts.Close()
	org := cf.OrganizationFields{}
	org.Name = "my-org"
	org.Guid = "my-org-guid"

	space := cf.SpaceFields{}
	space.Name = "my-space"
	space.Guid = "my-space-guid"

	config, _ := configRepo.Get()
	config.OrganizationFields = org
	config.SpaceFields = space

	repo.UpdateEndpoint(ts.URL)

	savedConfig := testconfig.SavedConfiguration

	assert.Equal(t, savedConfig.AccessToken, "")
	assert.Equal(t, savedConfig.AuthorizationEndpoint, "https://login.example.com")
	assert.Equal(t, savedConfig.Target, ts.URL)
	assert.Equal(t, savedConfig.ApiVersion, "42.0.0")
	assert.False(t, savedConfig.HasOrganization())
	assert.False(t, savedConfig.HasSpace())
}
开发者ID:pmuellr,项目名称:cli,代码行数:30,代码来源:endpoints_test.go

示例2: TestUpdateEndpointWhenUrlIsAlreadyTargeted

func TestUpdateEndpointWhenUrlIsAlreadyTargeted(t *testing.T) {
	configRepo := testconfig.FakeConfigRepository{}
	configRepo.Delete()
	configRepo.Login()

	ts, repo := createEndpointRepoForUpdate(configRepo, validApiInfoEndpoint)
	defer ts.Close()

	org := cf.OrganizationFields{}
	org.Name = "my-org"
	org.Guid = "my-org-guid"

	space := cf.SpaceFields{}
	space.Name = "my-space"
	space.Guid = "my-space-guid"

	config, _ := configRepo.Get()
	config.Target = ts.URL
	config.AccessToken = "some access token"
	config.RefreshToken = "some refresh token"
	config.OrganizationFields = org
	config.SpaceFields = space

	repo.UpdateEndpoint(ts.URL)

	assert.Equal(t, config.OrganizationFields, org)
	assert.Equal(t, config.SpaceFields, space)
	assert.Equal(t, config.AccessToken, "some access token")
	assert.Equal(t, config.RefreshToken, "some refresh token")
}
开发者ID:pmuellr,项目名称:cli,代码行数:30,代码来源:endpoints_test.go

示例3: testSuccessfulAuthenticate

func testSuccessfulAuthenticate(t *testing.T, args []string) (ui *testterm.FakeUI) {
	configRepo := testconfig.FakeConfigRepository{}
	configRepo.Delete()
	config, _ := configRepo.Get()

	auth := &testapi.FakeAuthenticationRepository{
		AccessToken:  "my_access_token",
		RefreshToken: "my_refresh_token",
		ConfigRepo:   configRepo,
	}
	ui = callAuthenticate(
		args,
		configRepo,
		auth,
	)

	savedConfig := testconfig.SavedConfiguration

	assert.Contains(t, ui.Outputs[0], config.Target)
	assert.Contains(t, ui.Outputs[2], "OK")

	assert.Equal(t, savedConfig.AccessToken, "my_access_token")
	assert.Equal(t, savedConfig.RefreshToken, "my_refresh_token")
	assert.Equal(t, auth.Email, "[email protected]")
	assert.Equal(t, auth.Password, "password")

	return
}
开发者ID:jalateras,项目名称:cli,代码行数:28,代码来源:authenticate_test.go

示例4: setupAuthWithEndpoint

func setupAuthWithEndpoint(t *testing.T, request testnet.TestRequest) (ts *httptest.Server, handler *testnet.TestHandler, auth UAAAuthenticationRepository) {
	ts, handler = testnet.NewTLSServer(t, []testnet.TestRequest{request})

	configRepo := testconfig.FakeConfigRepository{}
	configRepo.Delete()
	config, err := configRepo.Get()
	assert.NoError(t, err)
	config.AuthorizationEndpoint = ts.URL
	config.AccessToken = ""

	gateway := net.NewUAAGateway()

	auth = NewUAAAuthenticationRepository(gateway, configRepo)
	return
}
开发者ID:nsnt,项目名称:cli,代码行数:15,代码来源:authentication_test.go

示例5: createAuthenticationRepository

func createAuthenticationRepository(t *testing.T, apiServer *httptest.Server, authServer *httptest.Server) (*configuration.Configuration, api.AuthenticationRepository) {
	configRepo := testconfig.FakeConfigRepository{}
	configRepo.Delete()
	config, err := configRepo.Get()
	assert.NoError(t, err)

	config.AuthorizationEndpoint = authServer.URL
	config.Target = apiServer.URL
	config.AccessToken = "bearer initial-access-token"
	config.RefreshToken = "initial-refresh-token"

	authGateway := NewUAAGateway()
	authenticator := api.NewUAAAuthenticationRepository(authGateway, configRepo)

	return config, authenticator
}
开发者ID:nsnt,项目名称:cli,代码行数:16,代码来源:gateway_test.go

示例6: TestUnsuccessfullyAuthenticatingWithoutInteractivity

func TestUnsuccessfullyAuthenticatingWithoutInteractivity(t *testing.T) {
	configRepo := testconfig.FakeConfigRepository{}
	configRepo.Delete()
	config, _ := configRepo.Get()

	ui := callAuthenticate(
		[]string{
			"[email protected]",
			"bar",
		},
		configRepo,
		&testapi.FakeAuthenticationRepository{AuthError: true, ConfigRepo: configRepo},
	)

	assert.Contains(t, ui.Outputs[0], config.Target)
	assert.Equal(t, ui.Outputs[1], "Authenticating...")
	assert.Equal(t, ui.Outputs[2], "FAILED")
	assert.Contains(t, ui.Outputs[3], "Error authenticating")
	assert.Equal(t, len(ui.Outputs), 4)
}
开发者ID:jalateras,项目名称:cli,代码行数:20,代码来源:authenticate_test.go

示例7: TestAuthenticateFailsWithUsage

func TestAuthenticateFailsWithUsage(t *testing.T) {
	configRepo := testconfig.FakeConfigRepository{}
	configRepo.Delete()

	auth := &testapi.FakeAuthenticationRepository{
		AccessToken:  "my_access_token",
		RefreshToken: "my_refresh_token",
		ConfigRepo:   configRepo,
	}

	ui := callAuthenticate([]string{}, configRepo, auth)
	assert.True(t, ui.FailedWithUsage)

	ui = callAuthenticate([]string{"my-username"}, configRepo, auth)
	assert.True(t, ui.FailedWithUsage)

	ui = callAuthenticate([]string{"my-username", "my-password"}, configRepo, auth)
	assert.False(t, ui.FailedWithUsage)

}
开发者ID:jalateras,项目名称:cli,代码行数:20,代码来源:authenticate_test.go

示例8: TestUpdateEndpointWhenUrlIsMissingSchemeAndHttpsEndpointExists

func TestUpdateEndpointWhenUrlIsMissingSchemeAndHttpsEndpointExists(t *testing.T) {
	configRepo := testconfig.FakeConfigRepository{}
	configRepo.Delete()
	configRepo.Login()

	ts, repo := createEndpointRepoForUpdate(configRepo, validApiInfoEndpoint)
	defer ts.Close()

	schemelessURL := strings.Replace(ts.URL, "https://", "", 1)
	endpoint, apiResponse := repo.UpdateEndpoint(schemelessURL)
	assert.Equal(t, "https://"+schemelessURL, endpoint)

	assert.True(t, apiResponse.IsSuccessful())

	savedConfig := testconfig.SavedConfiguration

	assert.Equal(t, savedConfig.AccessToken, "")
	assert.Equal(t, savedConfig.AuthorizationEndpoint, "https://login.example.com")
	assert.Equal(t, savedConfig.Target, ts.URL)
	assert.Equal(t, savedConfig.ApiVersion, "42.0.0")
}
开发者ID:pmuellr,项目名称:cli,代码行数:21,代码来源:endpoints_test.go


注:本文中的testhelpers/configuration.FakeConfigRepository.Delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。