當前位置: 首頁>>代碼示例>>Golang>>正文


Golang ServiceInstance.Guid方法代碼示例

本文整理匯總了Golang中cf.ServiceInstance.Guid方法的典型用法代碼示例。如果您正苦於以下問題:Golang ServiceInstance.Guid方法的具體用法?Golang ServiceInstance.Guid怎麽用?Golang ServiceInstance.Guid使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在cf.ServiceInstance的用法示例。


在下文中一共展示了ServiceInstance.Guid方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: TestBindCommand

func TestBindCommand(t *testing.T) {
	app := cf.Application{}
	app.Name = "my-app"
	app.Guid = "my-app-guid"
	serviceInstance := cf.ServiceInstance{}
	serviceInstance.Name = "my-service"
	serviceInstance.Guid = "my-service-guid"
	reqFactory := &testreq.FakeReqFactory{
		Application:     app,
		ServiceInstance: serviceInstance,
	}
	serviceBindingRepo := &testapi.FakeServiceBindingRepo{}
	ui := callBindService(t, []string{"my-app", "my-service"}, reqFactory, serviceBindingRepo)

	assert.Equal(t, reqFactory.ApplicationName, "my-app")
	assert.Equal(t, reqFactory.ServiceInstanceName, "my-service")

	assert.Equal(t, len(ui.Outputs), 3)
	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Binding service", "my-service", "my-app", "my-org", "my-space", "my-user"},
		{"OK"},
		{"TIP"},
	})
	assert.Equal(t, serviceBindingRepo.CreateServiceInstanceGuid, "my-service-guid")
	assert.Equal(t, serviceBindingRepo.CreateApplicationGuid, "my-app-guid")
}
開發者ID:nsnt,項目名稱:cli,代碼行數:26,代碼來源:bind_service_test.go

示例2: TestShowServiceOutput

func TestShowServiceOutput(t *testing.T) {
	offering := cf.ServiceOfferingFields{}
	offering.Label = "mysql"
	offering.DocumentationUrl = "http://documentation.url"
	offering.Description = "the-description"

	plan := cf.ServicePlanFields{}
	plan.Guid = "plan-guid"
	plan.Name = "plan-name"

	serviceInstance := cf.ServiceInstance{}
	serviceInstance.Name = "service1"
	serviceInstance.Guid = "service1-guid"
	serviceInstance.ServicePlan = plan
	serviceInstance.ServiceOffering = offering
	reqFactory := &testreq.FakeReqFactory{
		LoginSuccess:         true,
		TargetedSpaceSuccess: true,
		ServiceInstance:      serviceInstance,
	}
	ui := callShowService([]string{"service1"}, reqFactory)

	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Service instance:", "service1"},
		{"Service: ", "mysql"},
		{"Plan: ", "plan-name"},
		{"Description: ", "the-description"},
		{"Documentation url: ", "http://documentation.url"},
	})
}
開發者ID:nsnt,項目名稱:cli,代碼行數:30,代碼來源:show_service_test.go

示例3: TestUnbindCommandWhenBindingIsNonExistent

func TestUnbindCommandWhenBindingIsNonExistent(t *testing.T) {
	app := cf.Application{}
	app.Name = "my-app"
	app.Guid = "my-app-guid"
	serviceInstance := cf.ServiceInstance{}
	serviceInstance.Name = "my-service"
	serviceInstance.Guid = "my-service-guid"
	reqFactory := &testreq.FakeReqFactory{
		Application:     app,
		ServiceInstance: serviceInstance,
	}
	serviceBindingRepo := &testapi.FakeServiceBindingRepo{DeleteBindingNotFound: true}
	ui := callUnbindService(t, []string{"my-app", "my-service"}, reqFactory, serviceBindingRepo)

	assert.Equal(t, reqFactory.ApplicationName, "my-app")
	assert.Equal(t, reqFactory.ServiceInstanceName, "my-service")

	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Unbinding app", "my-service", "my-app"},
		{"OK"},
		{"my-service", "my-app", "did not exist"},
	})
	assert.Equal(t, serviceBindingRepo.DeleteServiceInstance, serviceInstance)
	assert.Equal(t, serviceBindingRepo.DeleteApplicationGuid, "my-app-guid")
}
開發者ID:nsnt,項目名稱:cli,代碼行數:25,代碼來源:unbind_service_test.go

示例4: TestRenameService

func TestRenameService(t *testing.T) {
	path := "/v2/service_instances/my-service-instance-guid"
	serviceInstance := cf.ServiceInstance{}
	serviceInstance.Guid = "my-service-instance-guid"

	plan := cf.ServicePlanFields{}
	plan.Guid = "some-plan-guid"
	serviceInstance.ServicePlan = plan

	testRenameService(t, path, serviceInstance)
}
開發者ID:nsnt,項目名稱:cli,代碼行數:11,代碼來源:services_test.go

示例5: TestDeleteServiceBindingWhenBindingDoesNotExist

func TestDeleteServiceBindingWhenBindingDoesNotExist(t *testing.T) {
	ts, handler, repo := createServiceBindingRepo(t, []testnet.TestRequest{})
	defer ts.Close()

	serviceInstance := cf.ServiceInstance{}
	serviceInstance.Guid = "my-service-instance-guid"

	found, apiResponse := repo.Delete(serviceInstance, "app-2-guid")

	assert.Equal(t, handler.CallCount, 0)
	assert.False(t, apiResponse.IsNotSuccessful())
	assert.False(t, found)
}
開發者ID:pmuellr,項目名稱:cli,代碼行數:13,代碼來源:service_bindings_test.go

示例6: TestServiceInstanceReqExecute

func TestServiceInstanceReqExecute(t *testing.T) {
	instance := cf.ServiceInstance{}
	instance.Name = "my-service"
	instance.Guid = "my-service-guid"
	repo := &testapi.FakeServiceRepo{FindInstanceByNameServiceInstance: instance}
	ui := new(testterm.FakeUI)

	req := newServiceInstanceRequirement("foo", ui, repo)
	success := req.Execute()

	assert.True(t, success)
	assert.Equal(t, repo.FindInstanceByNameName, "foo")
	assert.Equal(t, req.GetServiceInstance(), instance)
}
開發者ID:nsnt,項目名稱:cli,代碼行數:14,代碼來源:service_instance_test.go

示例7: TestDeleteServiceWithoutServiceBindings

func TestDeleteServiceWithoutServiceBindings(t *testing.T) {
	req := testapi.NewCloudControllerTestRequest(testnet.TestRequest{
		Method:   "DELETE",
		Path:     "/v2/service_instances/my-service-instance-guid",
		Response: testnet.TestResponse{Status: http.StatusOK},
	})

	ts, handler, repo := createServiceRepo(t, []testnet.TestRequest{req})
	defer ts.Close()
	serviceInstance := cf.ServiceInstance{}
	serviceInstance.Guid = "my-service-instance-guid"
	apiResponse := repo.DeleteService(serviceInstance)
	assert.True(t, handler.AllRequestsCalled())
	assert.False(t, apiResponse.IsNotSuccessful())
}
開發者ID:nsnt,項目名稱:cli,代碼行數:15,代碼來源:services_test.go

示例8: TestRenameService

func TestRenameService(t *testing.T) {
	serviceInstance := cf.ServiceInstance{}
	serviceInstance.Name = "different-name"
	serviceInstance.Guid = "different-name-guid"
	reqFactory := &testreq.FakeReqFactory{LoginSuccess: true, TargetedSpaceSuccess: true, ServiceInstance: serviceInstance}
	ui, fakeServiceRepo := callRenameService(t, []string{"my-service", "new-name"}, reqFactory)

	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Renaming service", "different-name", "new-name", "my-org", "my-space", "my-user"},
		{"OK"},
	})

	assert.Equal(t, fakeServiceRepo.RenameServiceServiceInstance, serviceInstance)
	assert.Equal(t, fakeServiceRepo.RenameServiceNewName, "new-name")
}
開發者ID:nsnt,項目名稱:cli,代碼行數:15,代碼來源:rename_service_test.go

示例9: TestShowUserProvidedServiceOutput

func TestShowUserProvidedServiceOutput(t *testing.T) {
	serviceInstance2 := cf.ServiceInstance{}
	serviceInstance2.Name = "service1"
	serviceInstance2.Guid = "service1-guid"
	reqFactory := &testreq.FakeReqFactory{
		LoginSuccess:         true,
		TargetedSpaceSuccess: true,
		ServiceInstance:      serviceInstance2,
	}
	ui := callShowService([]string{"service1"}, reqFactory)

	assert.Equal(t, len(ui.Outputs), 3)
	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Service instance: ", "service1"},
		{"Service: ", "user-provided"},
	})
}
開發者ID:nsnt,項目名稱:cli,代碼行數:17,代碼來源:show_service_test.go

示例10: TestDeleteServiceCommandWithYes

func TestDeleteServiceCommandWithYes(t *testing.T) {
	serviceInstance := cf.ServiceInstance{}
	serviceInstance.Name = "my-service"
	serviceInstance.Guid = "my-service-guid"
	reqFactory := &testreq.FakeReqFactory{}
	serviceRepo := &testapi.FakeServiceRepo{FindInstanceByNameServiceInstance: serviceInstance}
	ui := callDeleteService(t, "Yes", []string{"my-service"}, reqFactory, serviceRepo)

	testassert.SliceContains(t, ui.Prompts, testassert.Lines{{"Are you sure"}})

	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Deleting service", "my-service"},
		{"OK"},
	})

	assert.Equal(t, serviceRepo.DeleteServiceServiceInstance, serviceInstance)
}
開發者ID:nsnt,項目名稱:cli,代碼行數:17,代碼來源:delete_service_test.go

示例11: TestDeleteServiceWithServiceBindings

func TestDeleteServiceWithServiceBindings(t *testing.T) {
	_, _, repo := createServiceRepo(t, []testnet.TestRequest{})

	serviceInstance := cf.ServiceInstance{}
	serviceInstance.Guid = "my-service-instance-guid"

	binding := cf.ServiceBindingFields{}
	binding.Url = "/v2/service_bindings/service-binding-1-guid"
	binding.AppGuid = "app-1-guid"

	binding2 := cf.ServiceBindingFields{}
	binding2.Url = "/v2/service_bindings/service-binding-2-guid"
	binding2.AppGuid = "app-2-guid"

	serviceInstance.ServiceBindings = []cf.ServiceBindingFields{binding, binding2}

	apiResponse := repo.DeleteService(serviceInstance)
	assert.True(t, apiResponse.IsNotSuccessful())
	assert.Equal(t, apiResponse.Message, "Cannot delete service instance, apps are still bound to it")
}
開發者ID:nsnt,項目名稱:cli,代碼行數:20,代碼來源:services_test.go

示例12: TestDeleteServiceBinding

func TestDeleteServiceBinding(t *testing.T) {
	ts, handler, repo := createServiceBindingRepo(t, []testnet.TestRequest{deleteBindingReq})
	defer ts.Close()

	serviceInstance := cf.ServiceInstance{}
	serviceInstance.Guid = "my-service-instance-guid"

	binding := cf.ServiceBindingFields{}
	binding.Url = "/v2/service_bindings/service-binding-1-guid"
	binding.AppGuid = "app-1-guid"
	binding2 := cf.ServiceBindingFields{}
	binding2.Url = "/v2/service_bindings/service-binding-2-guid"
	binding2.AppGuid = "app-2-guid"
	serviceInstance.ServiceBindings = []cf.ServiceBindingFields{binding, binding2}

	found, apiResponse := repo.Delete(serviceInstance, "app-2-guid")

	assert.True(t, handler.AllRequestsCalled())
	assert.False(t, apiResponse.IsNotSuccessful())
	assert.True(t, found)
}
開發者ID:pmuellr,項目名稱:cli,代碼行數:21,代碼來源:service_bindings_test.go

示例13: TestBindCommandIfServiceIsAlreadyBound

func TestBindCommandIfServiceIsAlreadyBound(t *testing.T) {
	app := cf.Application{}
	app.Name = "my-app"
	app.Guid = "my-app-guid"
	serviceInstance := cf.ServiceInstance{}
	serviceInstance.Name = "my-service"
	serviceInstance.Guid = "my-service-guid"
	reqFactory := &testreq.FakeReqFactory{
		Application:     app,
		ServiceInstance: serviceInstance,
	}
	serviceBindingRepo := &testapi.FakeServiceBindingRepo{CreateErrorCode: "90003"}
	ui := callBindService(t, []string{"my-app", "my-service"}, reqFactory, serviceBindingRepo)

	assert.Equal(t, len(ui.Outputs), 3)
	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Binding service"},
		{"OK"},
		{"my-app", "is already bound", "my-service"},
	})
}
開發者ID:nsnt,項目名稱:cli,代碼行數:21,代碼來源:bind_service_test.go

示例14: TestRenameServiceWhenServiceIsUserProvided

func TestRenameServiceWhenServiceIsUserProvided(t *testing.T) {
	path := "/v2/user_provided_service_instances/my-service-instance-guid"
	serviceInstance := cf.ServiceInstance{}
	serviceInstance.Guid = "my-service-instance-guid"
	testRenameService(t, path, serviceInstance)
}
開發者ID:nsnt,項目名稱:cli,代碼行數:6,代碼來源:services_test.go


注:本文中的cf.ServiceInstance.Guid方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。