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


Golang assert.SliceContains函数代码示例

本文整理汇总了Golang中testhelpers/assert.SliceContains函数的典型用法代码示例。如果您正苦于以下问题:Golang SliceContains函数的具体用法?Golang SliceContains怎么用?Golang SliceContains使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: TestPasswordCanBeChanged

func TestPasswordCanBeChanged(t *testing.T) {
	reqFactory := &testreq.FakeReqFactory{ValidAccessTokenSuccess: true}
	pwdRepo := &testapi.FakePasswordRepo{Score: "meh"}
	configRepo := &testconfig.FakeConfigRepository{}
	ui := callPassword([]string{"old-password", "new-password", "new-password"}, reqFactory, pwdRepo, configRepo)

	testassert.SliceContains(t, ui.PasswordPrompts, testassert.Lines{
		{"Current Password"},
		{"New Password"},
		{"Verify Password"},
	})

	assert.Equal(t, pwdRepo.ScoredPassword, "new-password")
	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Your password strength is: meh"},
		{"Changing password..."},
		{"OK"},
		{"Please log in again"},
	})

	assert.Equal(t, pwdRepo.UpdateNewPassword, "new-password")
	assert.Equal(t, pwdRepo.UpdateOldPassword, "old-password")

	updatedConfig, err := configRepo.Get()
	assert.NoError(t, err)
	assert.Empty(t, updatedConfig.AccessToken)
	assert.Equal(t, updatedConfig.OrganizationFields, cf.OrganizationFields{})
	assert.Equal(t, updatedConfig.SpaceFields, cf.SpaceFields{})
}
开发者ID:pmuellr,项目名称:cli,代码行数:29,代码来源:password_test.go

示例2: TestCreateUserProvidedServiceWithParameterList

func TestCreateUserProvidedServiceWithParameterList(t *testing.T) {
	repo := &testapi.FakeUserProvidedServiceInstanceRepo{}
	ui := callCreateUserProvidedService(t,
		[]string{"-p", `"foo, bar, baz"`, "my-custom-service"},
		[]string{"foo value", "bar value", "baz value"},
		repo,
	)

	testassert.SliceContains(t, ui.Prompts, testassert.Lines{
		{"foo"},
		{"bar"},
		{"baz"},
	})

	assert.Equal(t, repo.CreateName, "my-custom-service")
	assert.Equal(t, repo.CreateParams, map[string]string{
		"foo": "foo value",
		"bar": "bar value",
		"baz": "baz value",
	})

	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Creating user provided service", "my-custom-service", "my-org", "my-space", "my-user"},
		{"OK"},
	})
}
开发者ID:nsnt,项目名称:cli,代码行数:26,代码来源:create_user_provided_service_test.go

示例3: TestPasswordCanBeChanged

func TestPasswordCanBeChanged(t *testing.T) {
	deps := getPasswordDeps()
	deps.ReqFactory.ValidAccessTokenSuccess = true
	deps.PwdRepo.UpdateUnauthorized = false
	ui := callPassword([]string{"old-password", "new-password", "new-password"}, deps)

	testassert.SliceContains(t, ui.PasswordPrompts, testassert.Lines{
		{"Current Password"},
		{"New Password"},
		{"Verify Password"},
	})

	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Changing password..."},
		{"OK"},
		{"Please log in again"},
	})

	assert.Equal(t, deps.PwdRepo.UpdateNewPassword, "new-password")
	assert.Equal(t, deps.PwdRepo.UpdateOldPassword, "old-password")

	updatedConfig, err := deps.ConfigRepo.Get()
	assert.NoError(t, err)
	assert.Empty(t, updatedConfig.AccessToken)
	assert.Equal(t, updatedConfig.OrganizationFields, cf.OrganizationFields{})
	assert.Equal(t, updatedConfig.SpaceFields, cf.SpaceFields{})
}
开发者ID:nsnt,项目名称:cli,代码行数:27,代码来源:password_test.go

示例4: TestPushCommandHelpOutput

func TestPushCommandHelpOutput(t *testing.T) {
	reqFactory := &testreq.FakeReqFactory{}
	cmdRunner := commands.NewRunner(nil, reqFactory)
	app, _ := NewApp(cmdRunner)

	var updateCommand, pushCommand cli.Command
	for _, cmd := range app.Commands {
		if cmd.Name == "push" {
			pushCommand = cmd
		} else if cmd.Name == "update-buildpack" {
			updateCommand = cmd
		}
	}

	flags := []string{}
	for _, flag := range pushCommand.Flags {
		flags = append(flags, flag.String())
	}

	testassert.SliceContains(t, flags, testassert.Lines{
		{"-b \tCustom buildpack URL (e.g. https://github.com/heroku/heroku-buildpack-play.git)"},
	})

	flags = []string{}
	for _, flag := range updateCommand.Flags {
		flags = append(flags, flag.String())
	}

	testassert.SliceContains(t, flags, testassert.Lines{
		{"-i \tBuildpack position among other buildpacks"},
	})
}
开发者ID:nsnt,项目名称:cli,代码行数:32,代码来源:app_test.go

示例5: TestDeleteRouteWithConfirmation

func TestDeleteRouteWithConfirmation(t *testing.T) {
	domain := cf.DomainFields{}
	domain.Guid = "domain-guid"
	domain.Name = "example.com"
	reqFactory := &testreq.FakeReqFactory{LoginSuccess: true}
	route := cf.Route{}
	route.Guid = "route-guid"
	route.Host = "my-host"
	route.Domain = domain
	routeRepo := &testapi.FakeRouteRepository{
		FindByHostAndDomainRoute: route,
	}

	ui := callDeleteRoute(t, "y", []string{"-n", "my-host", "example.com"}, reqFactory, routeRepo)

	testassert.SliceContains(t, ui.Prompts, testassert.Lines{
		{"Really delete", "my-host"},
	})

	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Deleting route", "my-host.example.com"},
		{"OK"},
	})
	assert.Equal(t, routeRepo.DeleteRouteGuid, "route-guid")
}
开发者ID:nsnt,项目名称:cli,代码行数:25,代码来源:delete_route_test.go

示例6: TestDeleteBuildpackSuccess

func TestDeleteBuildpackSuccess(t *testing.T) {
	ui := &testterm.FakeUI{Inputs: []string{"y"}}
	buildpack := cf.Buildpack{}
	buildpack.Name = "my-buildpack"
	buildpack.Guid = "my-buildpack-guid"
	buildpackRepo := &testapi.FakeBuildpackRepository{
		FindByNameBuildpack: buildpack,
	}
	cmd := NewDeleteBuildpack(ui, buildpackRepo)

	ctxt := testcmd.NewContext("delete-buildpack", []string{"my-buildpack"})
	reqFactory := &testreq.FakeReqFactory{LoginSuccess: true}

	testcmd.RunCommand(cmd, ctxt, reqFactory)

	assert.Equal(t, buildpackRepo.DeleteBuildpackGuid, "my-buildpack-guid")

	testassert.SliceContains(t, ui.Prompts, testassert.Lines{
		{"delete", "my-buildpack"},
	})
	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Deleting buildpack", "my-buildpack"},
		{"OK"},
	})
}
开发者ID:nsnt,项目名称:cli,代码行数:25,代码来源:delete_buildpack_test.go

示例7: TestDeleteSpaceConfirmingWithYes

func TestDeleteSpaceConfirmingWithYes(t *testing.T) {
	ui, spaceRepo := deleteSpace(t, []string{"Yes"}, []string{"space-to-delete"}, defaultDeleteSpaceReqFactory())

	testassert.SliceContains(t, ui.Prompts, testassert.Lines{
		{"Really delete", "space-to-delete"},
	})
	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Deleting space", "space-to-delete", "my-org", "my-user"},
		{"OK"},
	})
	assert.Equal(t, spaceRepo.DeletedSpaceGuid, "space-to-delete-guid")
}
开发者ID:nsnt,项目名称:cli,代码行数:12,代码来源:delete_space_test.go

示例8: TestDeleteConfirmingWithY

func TestDeleteConfirmingWithY(t *testing.T) {
	ui, _, appRepo := deleteApp(t, "y", []string{"app-to-delete"})

	assert.Equal(t, appRepo.ReadName, "app-to-delete")
	assert.Equal(t, appRepo.DeletedAppGuid, "app-to-delete-guid")
	testassert.SliceContains(t, ui.Prompts, testassert.Lines{
		{"Really delete"},
	})
	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Deleting", "app-to-delete", "my-org", "my-space", "my-user"},
		{"OK"},
	})
}
开发者ID:nsnt,项目名称:cli,代码行数:13,代码来源:delete_app_test.go

示例9: TestDeleteConfirmingWithY

func TestDeleteConfirmingWithY(t *testing.T) {
	ui, _, repo := deleteServiceBroker(t, "y", []string{"service-broker-to-delete"})

	assert.Equal(t, repo.FindByNameName, "service-broker-to-delete")
	assert.Equal(t, repo.DeletedServiceBrokerGuid, "service-broker-to-delete-guid")
	assert.Equal(t, len(ui.Outputs), 2)
	testassert.SliceContains(t, ui.Prompts, testassert.Lines{
		{"Really delete", "service-broker-to-delete"},
	})
	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Deleting service broker", "service-broker-to-delete", "my-user"},
		{"OK"},
	})
}
开发者ID:nsnt,项目名称:cli,代码行数:14,代码来源:delete_service_broker_test.go

示例10: TestSetSpaceRole

func TestSetSpaceRole(t *testing.T) {
	org := cf.Organization{}
	org.Guid = "my-org-guid"
	org.Name = "my-org"

	args := []string{"some-user", "some-org", "some-space", "SpaceManager"}

	reqFactory, spaceRepo, userRepo := getSetSpaceRoleDeps()
	reqFactory.LoginSuccess = true
	reqFactory.UserFields = cf.UserFields{}
	reqFactory.UserFields.Guid = "my-user-guid"
	reqFactory.UserFields.Username = "my-user"
	reqFactory.Organization = org

	spaceRepo.FindByNameInOrgSpace = cf.Space{}
	spaceRepo.FindByNameInOrgSpace.Guid = "my-space-guid"
	spaceRepo.FindByNameInOrgSpace.Name = "my-space"
	spaceRepo.FindByNameInOrgSpace.Organization = org.OrganizationFields

	ui := callSetSpaceRole(t, args, reqFactory, spaceRepo, userRepo)

	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Assigning role ", "SpaceManager", "my-user", "my-org", "my-space", "current-user"},
		{"OK"},
	})

	assert.Equal(t, spaceRepo.FindByNameInOrgName, "some-space")
	assert.Equal(t, spaceRepo.FindByNameInOrgOrgGuid, "my-org-guid")

	assert.Equal(t, userRepo.SetSpaceRoleUserGuid, "my-user-guid")
	assert.Equal(t, userRepo.SetSpaceRoleSpaceGuid, "my-space-guid")
	assert.Equal(t, userRepo.SetSpaceRoleRole, cf.SPACE_MANAGER)
}
开发者ID:nsnt,项目名称:cli,代码行数:33,代码来源:set_space_role_test.go

示例11: TestEmptyServicesList

func TestEmptyServicesList(t *testing.T) {
	serviceInstances := []cf.ServiceInstance{}
	serviceSummaryRepo := &testapi.FakeServiceSummaryRepo{
		GetSummariesInCurrentSpaceInstances: serviceInstances,
	}
	ui := &testterm.FakeUI{}

	token, err := testconfig.CreateAccessTokenWithTokenInfo(configuration.TokenInfo{
		Username: "my-user",
	})
	assert.NoError(t, err)
	org := cf.OrganizationFields{}
	org.Name = "my-org"
	space := cf.SpaceFields{}
	space.Name = "my-space"
	config := &configuration.Configuration{
		SpaceFields:        space,
		OrganizationFields: org,
		AccessToken:        token,
	}

	cmd := NewListServices(ui, config, serviceSummaryRepo)
	cmd.Run(testcmd.NewContext("services", []string{}))

	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Getting services in org", "my-org", "my-space", "my-user"},
		{"OK"},
		{"No services found"},
	})
	testassert.SliceDoesNotContain(t, ui.Outputs, testassert.Lines{
		{"name", "service", "plan", "bound apps"},
	})
}
开发者ID:nsnt,项目名称:cli,代码行数:33,代码来源:list_services_test.go

示例12: TestCreateServiceWhenServiceAlreadyExists

func TestCreateServiceWhenServiceAlreadyExists(t *testing.T) {
	offering := cf.ServiceOffering{}
	offering.Label = "cleardb"
	plan := cf.ServicePlanFields{}
	plan.Name = "spark"
	plan.Guid = "cleardb-spark-guid"
	offering.Plans = []cf.ServicePlanFields{plan}
	offering2 := cf.ServiceOffering{}
	offering2.Label = "postgres"
	serviceOfferings := []cf.ServiceOffering{offering, offering2}
	serviceRepo := &testapi.FakeServiceRepo{ServiceOfferings: serviceOfferings, CreateServiceAlreadyExists: true}
	ui := callCreateService(t,
		[]string{"cleardb", "spark", "my-cleardb-service"},
		[]string{},
		serviceRepo,
	)

	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Creating service", "my-cleardb-service"},
		{"OK"},
		{"my-cleardb-service", "already exists"},
	})
	assert.Equal(t, serviceRepo.CreateServiceInstanceName, "my-cleardb-service")
	assert.Equal(t, serviceRepo.CreateServiceInstancePlanGuid, "cleardb-spark-guid")
}
开发者ID:nsnt,项目名称:cli,代码行数:25,代码来源:create_service_test.go

示例13: TestParsingManifestWithNulls

func TestParsingManifestWithNulls(t *testing.T) {
	_, errs := manifest.NewManifest(generic.NewMap(map[string]interface{}{
		"applications": []interface{}{
			map[string]interface{}{
				"buildpack":  nil,
				"disk_quota": nil,
				"domain":     nil,
				"host":       nil,
				"name":       nil,
				"path":       nil,
				"stack":      nil,
				"memory":     nil,
				"instances":  nil,
				"timeout":    nil,
				"no-route":   nil,
				"services":   nil,
				"env":        nil,
			},
		},
	}))

	assert.Error(t, errs)
	errorSlice := strings.Split(errs.Error(), "\n")
	manifestKeys := []string{"buildpack", "disk_quota", "domain", "host", "name", "path", "stack",
		"memory", "instances", "timeout", "no-route", "services", "env"}

	for _, key := range manifestKeys {
		testassert.SliceContains(t, errorSlice, testassert.Lines{{key, "not be null"}})
	}
}
开发者ID:nsnt,项目名称:cli,代码行数:30,代码来源:manifest_test.go

示例14: TestListingSpaces

func TestListingSpaces(t *testing.T) {
	space := cf.Space{}
	space.Name = "space1"
	space2 := cf.Space{}
	space2.Name = "space2"
	space3 := cf.Space{}
	space3.Name = "space3"
	spaceRepo := &testapi.FakeSpaceRepository{
		Spaces: []cf.Space{space, space2, space3},
	}
	token, err := testconfig.CreateAccessTokenWithTokenInfo(configuration.TokenInfo{
		Username: "my-user",
	})

	assert.NoError(t, err)
	org := cf.OrganizationFields{}
	org.Name = "my-org"
	config := &configuration.Configuration{
		OrganizationFields: org,
		AccessToken:        token,
	}

	reqFactory := &testreq.FakeReqFactory{LoginSuccess: true, TargetedOrgSuccess: true}
	ui := callSpaces([]string{}, reqFactory, config, spaceRepo)
	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Getting spaces in org", "my-org", "my-user"},
		{"space1"},
		{"space2"},
		{"space3"},
	})
}
开发者ID:nsnt,项目名称:cli,代码行数:31,代码来源:list_spaces_test.go

示例15: TestPushingAppWhenItAlreadyExistsAndDomainIsSpecifiedIsAlreadyBound

func TestPushingAppWhenItAlreadyExistsAndDomainIsSpecifiedIsAlreadyBound(t *testing.T) {
	deps := getPushDependencies()

	domain := cf.DomainFields{}
	domain.Name = "example.com"
	domain.Guid = "domain-guid"

	existingRoute := cf.RouteSummary{}
	existingRoute.Host = "existing-app"
	existingRoute.Domain = domain

	existingApp := cf.Application{}
	existingApp.Name = "existing-app"
	existingApp.Guid = "existing-app-guid"
	existingApp.Routes = []cf.RouteSummary{existingRoute}

	foundRoute := cf.Route{}
	foundRoute.RouteFields = existingRoute.RouteFields
	foundRoute.Domain = existingRoute.Domain

	deps.appRepo.ReadApp = existingApp
	deps.appRepo.UpdateAppResult = existingApp
	deps.routeRepo.FindByHostAndDomainRoute = foundRoute

	ui := callPush(t, []string{"-d", "example.com", "existing-app"}, deps)

	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Using route", "existing-app", "example.com"},
	})
	assert.Equal(t, deps.appBitsRepo.UploadedAppGuid, "existing-app-guid")
}
开发者ID:nsnt,项目名称:cli,代码行数:31,代码来源:push_test.go


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