コード例 #1
0
ファイル: domain_mapper_test.go プロジェクト: pmuellr/cli
func callDomainMapper(t *testing.T, shouldMap bool, args []string, reqFactory *testreq.FakeReqFactory, domainRepo *testapi.FakeDomainRepository) (ui *testterm.FakeUI) {
	cmdName := "map-domain"
	if !shouldMap {
		cmdName = "unmap-domain"
	}

	ctxt := testcmd.NewContext(cmdName, args)
	ui = &testterm.FakeUI{}

	token, err := testconfig.CreateAccessTokenWithTokenInfo(configuration.TokenInfo{
		Username: "******",
	})
	assert.NoError(t, err)

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

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

	config := &configuration.Configuration{
		SpaceFields:        spaceFields,
		OrganizationFields: orgFields,
		AccessToken:        token,
	}

	cmd := domain.NewDomainMapper(ui, config, domainRepo, shouldMap)
	testcmd.RunCommand(cmd, ctxt, reqFactory)
	return
}
コード例 #2
0
ファイル: push_test.go プロジェクト: nsnt/cli
func TestPushingRequirements(t *testing.T) {
	ui := new(testterm.FakeUI)
	config := &configuration.Configuration{}
	deps := getPushDependencies()
	manifestRepo := deps.manifestRepo
	starter := deps.starter
	stopper := deps.stopper
	binder := deps.binder
	appRepo := deps.appRepo
	domainRepo := deps.domainRepo
	routeRepo := deps.routeRepo
	stackRepo := deps.stackRepo
	appBitsRepo := deps.appBitsRepo
	serviceRepo := deps.serviceRepo

	cmd := NewPush(ui, config, manifestRepo, starter, stopper, binder, appRepo, domainRepo, routeRepo, stackRepo, serviceRepo, appBitsRepo)
	ctxt := testcmd.NewContext("push", []string{})

	reqFactory := &testreq.FakeReqFactory{LoginSuccess: true, TargetedSpaceSuccess: true}
	assert.True(t, testcmd.CommandDidPassRequirements)

	reqFactory = &testreq.FakeReqFactory{LoginSuccess: false, TargetedSpaceSuccess: true}
	testcmd.RunCommand(cmd, ctxt, reqFactory)
	assert.False(t, testcmd.CommandDidPassRequirements)

	testcmd.CommandDidPassRequirements = true

	reqFactory = &testreq.FakeReqFactory{LoginSuccess: true, TargetedSpaceSuccess: false}
	testcmd.RunCommand(cmd, ctxt, reqFactory)
	assert.False(t, testcmd.CommandDidPassRequirements)
}
コード例 #3
0
ファイル: authenticate_test.go プロジェクト: jalateras/cli
func callAuthenticate(args []string, configRepo configuration.ConfigurationRepository, auth api.AuthenticationRepository) (ui *testterm.FakeUI) {
	ui = new(testterm.FakeUI)
	ctxt := testcmd.NewContext("auth", args)
	cmd := NewAuthenticate(ui, configRepo, auth)
	testcmd.RunCommand(cmd, ctxt, &testreq.FakeReqFactory{})
	return
}
コード例 #4
0
ファイル: delete_domain_test.go プロジェクト: nsnt/cli
func callDeleteDomain(t *testing.T, args []string, inputs []string, reqFactory *testreq.FakeReqFactory, domainRepo *testapi.FakeDomainRepository) (ui *testterm.FakeUI) {
	ctxt := testcmd.NewContext("delete-domain", args)
	ui = &testterm.FakeUI{
		Inputs: inputs,
	}

	token, err := testconfig.CreateAccessTokenWithTokenInfo(configuration.TokenInfo{
		Username: "******",
	})
	assert.NoError(t, err)

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

	orgFields := cf.OrganizationFields{}
	orgFields.Name = "my-org"
	config := &configuration.Configuration{
		SpaceFields:        spaceFields,
		OrganizationFields: orgFields,
		AccessToken:        token,
	}

	cmd := domain.NewDeleteDomain(ui, config, domainRepo)
	testcmd.RunCommand(cmd, ctxt, reqFactory)
	return
}
コード例 #5
0
func callDeleteServiceAuthToken(t *testing.T, args []string, inputs []string, reqFactory *testreq.FakeReqFactory, authTokenRepo *testapi.FakeAuthTokenRepo) (ui *testterm.FakeUI) {
	ui = &testterm.FakeUI{
		Inputs: inputs,
	}

	token, err := testconfig.CreateAccessTokenWithTokenInfo(configuration.TokenInfo{
		Username: "******",
	})
	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 := NewDeleteServiceAuthToken(ui, config, authTokenRepo)
	ctxt := testcmd.NewContext("delete-service-auth-token", args)

	testcmd.RunCommand(cmd, ctxt, reqFactory)
	return
}
コード例 #6
0
ファイル: list_services_test.go プロジェクト: nsnt/cli
func TestEmptyServicesList(t *testing.T) {
	serviceInstances := []cf.ServiceInstance{}
	serviceSummaryRepo := &testapi.FakeServiceSummaryRepo{
		GetSummariesInCurrentSpaceInstances: serviceInstances,
	}
	ui := &testterm.FakeUI{}

	token, err := testconfig.CreateAccessTokenWithTokenInfo(configuration.TokenInfo{
		Username: "******",
	})
	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"},
	})
}
コード例 #7
0
ファイル: list_quotas_test.go プロジェクト: nsnt/cli
func callListQuotas(t *testing.T, reqFactory *testreq.FakeReqFactory, quotaRepo *testapi.FakeQuotaRepository) (fakeUI *testterm.FakeUI) {
	fakeUI = &testterm.FakeUI{}
	ctxt := testcmd.NewContext("quotas", []string{})

	token, err := testconfig.CreateAccessTokenWithTokenInfo(configuration.TokenInfo{
		Username: "******",
	})
	assert.NoError(t, err)

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

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

	config := &configuration.Configuration{
		SpaceFields:        spaceFields,
		OrganizationFields: orgFields,
		AccessToken:        token,
	}

	cmd := organization.NewListQuotas(fakeUI, config, quotaRepo)
	testcmd.RunCommand(cmd, ctxt, reqFactory)
	return
}
コード例 #8
0
ファイル: delete_buildpack_test.go プロジェクト: nsnt/cli
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"},
	})
}
コード例 #9
0
ファイル: list_routes_test.go プロジェクト: nsnt/cli
func callListRoutes(t *testing.T, args []string, reqFactory *testreq.FakeReqFactory, routeRepo *testapi.FakeRouteRepository) (ui *testterm.FakeUI) {

	ui = &testterm.FakeUI{}

	ctxt := testcmd.NewContext("routes", args)

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

	cmd := NewListRoutes(ui, config, routeRepo)
	testcmd.RunCommand(cmd, ctxt, reqFactory)

	return
}
コード例 #10
0
func deleteServiceBroker(t *testing.T, confirmation string, args []string) (ui *testterm.FakeUI, reqFactory *testreq.FakeReqFactory, repo *testapi.FakeServiceBrokerRepo) {
	serviceBroker := cf.ServiceBroker{
		Name: "service-broker-to-delete",
		Guid: "service-broker-to-delete-guid",
	}

	reqFactory = &testreq.FakeReqFactory{LoginSuccess: true}
	repo = &testapi.FakeServiceBrokerRepo{FindByNameServiceBroker: serviceBroker}
	ui = &testterm.FakeUI{
		Inputs: []string{confirmation},
	}

	token, err := testconfig.CreateAccessTokenWithTokenInfo(configuration.TokenInfo{
		Username: "******",
	})
	assert.NoError(t, err)

	config := &configuration.Configuration{
		Space:        cf.Space{Name: "my-space"},
		Organization: cf.Organization{Name: "my-org"},
		AccessToken:  token,
	}

	ctxt := testcmd.NewContext("delete-service-broker", args)
	cmd := NewDeleteServiceBroker(ui, config, repo)
	testcmd.RunCommand(cmd, ctxt, reqFactory)
	return
}
コード例 #11
0
ファイル: login_test.go プロジェクト: jalateras/cli
func callLogin(t *testing.T, c *LoginTestContext, beforeBlock func(*LoginTestContext)) {

	// setup test fakes
	c.configRepo = testconfig.FakeConfigRepository{}
	c.ui = &testterm.FakeUI{
		Inputs: c.Inputs,
	}
	c.authRepo = &testapi.FakeAuthenticationRepository{
		AccessToken:  "my_access_token",
		RefreshToken: "my_refresh_token",
		ConfigRepo:   c.configRepo,
	}
	c.endpointRepo = &testapi.FakeEndpointRepo{}
	c.orgRepo = &testapi.FakeOrgRepository{
		FindByNameOrganization: cf.Organization{Name: "my-org", Guid: "my-org-guid"},
	}

	c.spaceRepo = &testapi.FakeSpaceRepository{
		FindByNameSpace: cf.Space{Name: "my-space", Guid: "my-space-guid"},
	}

	// initialize config
	c.configRepo.Delete()
	config, _ := c.configRepo.Get()
	config.Target = c.Config.Target
	config.Organization = c.Config.Organization
	config.Space = c.Config.Space

	// run any test-specific setup
	beforeBlock(c)

	// run login command
	l := NewLogin(c.ui, c.configRepo, c.authRepo, c.endpointRepo, c.orgRepo, c.spaceRepo)
	l.Run(testcmd.NewContext("login", c.Flags))
}
コード例 #12
0
ファイル: buildpacks_test.go プロジェクト: nota-ja/cli
func callListBuildpacks(requirementsFactory *testreq.FakeReqFactory, buildpackRepo *testapi.FakeBuildpackRepository) (ui *testterm.FakeUI) {
	ui = &testterm.FakeUI{}
	ctxt := testcmd.NewContext("buildpacks", []string{})
	cmd := buildpack.NewListBuildpacks(ui, buildpackRepo)
	testcmd.RunCommand(cmd, ctxt, requirementsFactory)
	return
}
コード例 #13
0
ファイル: delete_space_test.go プロジェクト: jalateras/cli
func deleteSpace(t *testing.T, confirmation string, args []string) (ui *testterm.FakeUI, spaceRepo *testapi.FakeSpaceRepository) {
	space := cf.Space{Name: "space-to-delete", Guid: "space-to-delete-guid"}
	reqFactory := &testreq.FakeReqFactory{}
	spaceRepo = &testapi.FakeSpaceRepository{FindByNameSpace: space}
	configRepo := &testconfig.FakeConfigRepository{}

	ui = &testterm.FakeUI{
		Inputs: []string{confirmation},
	}
	ctxt := testcmd.NewContext("delete-space", args)

	token, err := testconfig.CreateAccessTokenWithTokenInfo(configuration.TokenInfo{
		Username: "******",
	})
	assert.NoError(t, err)

	config := &configuration.Configuration{
		Space:        cf.Space{Name: "my-space"},
		Organization: cf.Organization{Name: "my-org"},
		AccessToken:  token,
	}

	cmd := NewDeleteSpace(ui, config, spaceRepo, configRepo)
	testcmd.RunCommand(cmd, ctxt, reqFactory)
	return
}
コード例 #14
0
ファイル: delete_app_test.go プロジェクト: nsnt/cli
func deleteApp(t *testing.T, confirmation string, args []string) (ui *testterm.FakeUI, reqFactory *testreq.FakeReqFactory, appRepo *testapi.FakeApplicationRepository) {

	app := cf.Application{}
	app.Name = "app-to-delete"
	app.Guid = "app-to-delete-guid"

	reqFactory = &testreq.FakeReqFactory{}
	appRepo = &testapi.FakeApplicationRepository{ReadApp: app}
	ui = &testterm.FakeUI{
		Inputs: []string{confirmation},
	}

	token, err := testconfig.CreateAccessTokenWithTokenInfo(configuration.TokenInfo{
		Username: "******",
	})
	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,
	}

	ctxt := testcmd.NewContext("delete", args)
	cmd := NewDeleteApp(ui, config, appRepo)
	testcmd.RunCommand(cmd, ctxt, reqFactory)
	return
}
コード例 #15
0
ファイル: stacks_test.go プロジェクト: nsnt/cli
func callStacks(t *testing.T, stackRepo *testapi.FakeStackRepository) (ui *testterm.FakeUI) {
	ui = &testterm.FakeUI{}

	ctxt := testcmd.NewContext("stacks", []string{})

	token, err := testconfig.CreateAccessTokenWithTokenInfo(configuration.TokenInfo{
		Username: "******",
	})
	assert.NoError(t, err)

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

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

	config := &configuration.Configuration{
		SpaceFields:        space,
		OrganizationFields: org,
		AccessToken:        token,
	}

	cmd := NewStacks(ui, config, stackRepo)
	testcmd.RunCommand(cmd, ctxt, nil)

	return
}
コード例 #16
0
ファイル: delete_buildpack_test.go プロジェクト: nsnt/cli
func TestDeleteBuildpackDeleteError(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,
		DeleteApiResponse:   net.NewApiResponseWithMessage("failed badly"),
	}

	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.Outputs, testassert.Lines{
		{"Deleting buildpack", "my-buildpack"},
		{"FAILED"},
		{"my-buildpack"},
		{"failed badly"},
	})
}
コード例 #17
0
ファイル: delete_user_test.go プロジェクト: knolleary/cli
func deleteWithConfirmation(confirmation string) (ui *testterm.FakeUI, userRepo *testapi.FakeUserRepository) {
	ui = &testterm.FakeUI{
		Inputs: []string{confirmation},
	}
	user2 := models.UserFields{}
	user2.Username = "******"
	user2.Guid = "my-found-user-guid"
	userRepo = &testapi.FakeUserRepository{
		FindByUsernameUserFields: user2,
	}

	configRepo := testconfig.NewRepositoryWithDefaults()
	accessToken, err := testconfig.EncodeAccessToken(configuration.TokenInfo{
		Username: "******",
	})
	Expect(err).NotTo(HaveOccurred())
	configRepo.SetAccessToken(accessToken)

	cmd := NewDeleteUser(ui, configRepo, userRepo)

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

	testcmd.RunCommand(cmd, ctxt, reqFactory)
	return
}
コード例 #18
0
ファイル: delete_buildpack_test.go プロジェクト: nsnt/cli
func TestDeleteBuildpackThatDoesNotExist(t *testing.T) {
	reqFactory := &testreq.FakeReqFactory{LoginSuccess: true}
	buildpack := cf.Buildpack{}
	buildpack.Name = "my-buildpack"
	buildpack.Guid = "my-buildpack-guid"
	buildpackRepo := &testapi.FakeBuildpackRepository{
		FindByNameNotFound:  true,
		FindByNameBuildpack: buildpack,
	}

	ui := &testterm.FakeUI{}
	ctxt := testcmd.NewContext("delete-buildpack", []string{"-f", "my-buildpack"})

	cmd := NewDeleteBuildpack(ui, buildpackRepo)
	testcmd.RunCommand(cmd, ctxt, reqFactory)

	assert.Equal(t, buildpackRepo.FindByNameName, "my-buildpack")
	assert.True(t, buildpackRepo.FindByNameNotFound)

	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Deleting", "my-buildpack"},
		{"OK"},
		{"my-buildpack", "does not exist"},
	})
}
コード例 #19
0
ファイル: rename_service_test.go プロジェクト: nsnt/cli
func callRenameService(t *testing.T, args []string, reqFactory *testreq.FakeReqFactory) (ui *testterm.FakeUI, serviceRepo *testapi.FakeServiceRepo) {
	ui = &testterm.FakeUI{}
	serviceRepo = &testapi.FakeServiceRepo{}

	token, err := testconfig.CreateAccessTokenWithTokenInfo(configuration.TokenInfo{
		Username: "******",
	})
	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 := NewRenameService(ui, config, serviceRepo)
	ctxt := testcmd.NewContext("rename-service", args)

	testcmd.RunCommand(cmd, ctxt, reqFactory)

	return
}
コード例 #20
0
ファイル: delete_org_test.go プロジェクト: nsnt/cli
func deleteOrg(t *testing.T, confirmation string, args []string, orgRepo *testapi.FakeOrgRepository) (ui *testterm.FakeUI) {
	reqFactory := &testreq.FakeReqFactory{}
	configRepo := &testconfig.FakeConfigRepository{}

	ui = &testterm.FakeUI{
		Inputs: []string{confirmation},
	}
	ctxt := testcmd.NewContext("delete-org", args)

	token, err := testconfig.CreateAccessTokenWithTokenInfo(configuration.TokenInfo{
		Username: "******",
	})
	assert.NoError(t, err)

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

	orgFields := cf.OrganizationFields{}
	orgFields.Name = "my-org"
	config := &configuration.Configuration{
		SpaceFields:        spaceFields,
		OrganizationFields: orgFields,
		AccessToken:        token,
	}

	cmd := NewDeleteOrg(ui, config, orgRepo, configRepo)
	testcmd.RunCommand(cmd, ctxt, reqFactory)
	return
}
コード例 #21
0
ファイル: rename_org_test.go プロジェクト: nsnt/cli
func callRenameOrg(t *testing.T, args []string, reqFactory *testreq.FakeReqFactory, orgRepo *testapi.FakeOrgRepository) (ui *testterm.FakeUI) {
	ui = new(testterm.FakeUI)
	ctxt := testcmd.NewContext("rename-org", args)

	token, err := testconfig.CreateAccessTokenWithTokenInfo(configuration.TokenInfo{
		Username: "******",
	})
	assert.NoError(t, err)

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

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

	config := &configuration.Configuration{
		SpaceFields:        spaceFields,
		OrganizationFields: orgFields,
		AccessToken:        token,
	}

	cmd := organization.NewRenameOrg(ui, config, orgRepo)
	testcmd.RunCommand(cmd, ctxt, reqFactory)
	return
}
コード例 #22
0
ファイル: show_service_test.go プロジェクト: nsnt/cli
func callShowService(args []string, reqFactory *testreq.FakeReqFactory) (ui *testterm.FakeUI) {
	ui = new(testterm.FakeUI)
	ctxt := testcmd.NewContext("service", args)
	cmd := NewShowService(ui)
	testcmd.RunCommand(cmd, ctxt, reqFactory)
	return
}
コード例 #23
0
ファイル: push_test.go プロジェクト: jalateras/cli
func callPush(t *testing.T,
	args []string,
	starter ApplicationStarter,
	stopper ApplicationStopper,
	appRepo api.ApplicationRepository,
	domainRepo api.DomainRepository,
	routeRepo api.RouteRepository,
	stackRepo api.StackRepository,
	appBitsRepo *testapi.FakeApplicationBitsRepository) (fakeUI *testterm.FakeUI) {

	fakeUI = new(testterm.FakeUI)
	ctxt := testcmd.NewContext("push", args)

	token, err := testconfig.CreateAccessTokenWithTokenInfo(configuration.TokenInfo{
		Username: "******",
	})
	assert.NoError(t, err)

	config := &configuration.Configuration{
		Space:        cf.Space{Name: "my-space"},
		Organization: cf.Organization{Name: "my-org"},
		AccessToken:  token,
	}

	cmd := NewPush(fakeUI, config, starter, stopper, appRepo, domainRepo, routeRepo, stackRepo, appBitsRepo)
	reqFactory := &testreq.FakeReqFactory{LoginSuccess: true, TargetedSpaceSuccess: true}
	testcmd.RunCommand(cmd, ctxt, reqFactory)

	return
}
コード例 #24
0
ファイル: delete_user_test.go プロジェクト: jalateras/cli
func deleteWithConfirmation(t *testing.T, confirmation string) (ui *testterm.FakeUI, userRepo *testapi.FakeUserRepository) {
	ui = &testterm.FakeUI{
		Inputs: []string{confirmation},
	}

	userRepo = &testapi.FakeUserRepository{
		FindByUsernameUser: cf.User{Username: "******", Guid: "my-found-user-guid"},
	}

	token, err := testconfig.CreateAccessTokenWithTokenInfo(configuration.TokenInfo{
		Username: "******",
	})
	assert.NoError(t, err)

	config := &configuration.Configuration{
		Space:        cf.Space{Name: "my-space"},
		Organization: cf.Organization{Name: "my-org"},
		AccessToken:  token,
	}

	cmd := NewDeleteUser(ui, config, userRepo)

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

	testcmd.RunCommand(cmd, ctxt, reqFactory)
	return
}
コード例 #25
0
ファイル: runner_test.go プロジェクト: nsnt/cli
func TestRun(t *testing.T) {
	passingReq := TestRequirement{Passes: true}
	failingReq := TestRequirement{Passes: false}
	lastReq := TestRequirement{Passes: true}

	cmd := TestCommand{
		Reqs: []requirements.Requirement{&passingReq, &failingReq, &lastReq},
	}

	cmdFactory := &TestCommandFactory{Cmd: &cmd}
	runner := NewRunner(cmdFactory, nil)

	ctxt := testcmd.NewContext("login", []string{})

	err := runner.RunCmdByName("some-cmd", ctxt)

	assert.Equal(t, cmdFactory.CmdName, "some-cmd")

	assert.True(t, passingReq.WasExecuted, ctxt)
	assert.True(t, failingReq.WasExecuted, ctxt)

	assert.False(t, lastReq.WasExecuted)
	assert.Nil(t, cmd.WasRunWith)

	assert.Error(t, err)
}
コード例 #26
0
ファイル: list_orgs_test.go プロジェクト: nsnt/cli
func callListOrgs(config *configuration.Configuration, reqFactory *testreq.FakeReqFactory, orgRepo *testapi.FakeOrgRepository) (fakeUI *testterm.FakeUI) {
	fakeUI = &testterm.FakeUI{}
	ctxt := testcmd.NewContext("orgs", []string{})
	cmd := organization.NewListOrgs(fakeUI, config, orgRepo)
	testcmd.RunCommand(cmd, ctxt, reqFactory)
	return
}
コード例 #27
0
ファイル: list_buildpacks_test.go プロジェクト: jalateras/cli
func callListBuildpacks(reqFactory *testreq.FakeReqFactory, buildpackRepo *testapi.FakeBuildpackRepository) (fakeUI *testterm.FakeUI) {
	fakeUI = &testterm.FakeUI{}
	ctxt := testcmd.NewContext("buildpacks", []string{})
	cmd := NewListBuildpacks(fakeUI, buildpackRepo)
	testcmd.RunCommand(cmd, ctxt, reqFactory)
	return
}
コード例 #28
0
ファイル: rename_org_test.go プロジェクト: normalnorman/cli
func callRenameOrg(args []string, reqFactory *testreq.FakeReqFactory, orgRepo *testapi.FakeOrgRepository) (ui *testterm.FakeUI) {
	ui = new(testterm.FakeUI)
	ctxt := testcmd.NewContext("rename-org", args)
	configRepo := testconfig.NewRepositoryWithDefaults()
	cmd := organization.NewRenameOrg(ui, configRepo, orgRepo)
	testcmd.RunCommand(cmd, ctxt, reqFactory)
	return
}
コード例 #29
0
ファイル: set_env_test.go プロジェクト: knolleary/cli
func callSetEnv(args []string, reqFactory *testreq.FakeReqFactory, appRepo api.ApplicationRepository) (ui *testterm.FakeUI) {
	ui = new(testterm.FakeUI)
	ctxt := testcmd.NewContext("set-env", args)
	configRepo := testconfig.NewRepositoryWithDefaults()
	cmd := NewSetEnv(ui, configRepo, appRepo)
	testcmd.RunCommand(cmd, ctxt, reqFactory)
	return
}
コード例 #30
0
ファイル: scale_test.go プロジェクト: normalnorman/cli
func callScale(args []string, deps scaleDependencies) (ui *testterm.FakeUI) {
	ui = new(testterm.FakeUI)
	ctxt := testcmd.NewContext("scale", args)
	configRepo := testconfig.NewRepositoryWithDefaults()
	cmd := NewScale(ui, configRepo, deps.restarter, deps.appRepo)
	testcmd.RunCommand(cmd, ctxt, deps.reqFactory)
	return
}