예제 #1
0
파일: push_test.go 프로젝트: jbayer/cli
func TestPushingRequirements(t *testing.T) {
	fakeUI := new(testhelpers.FakeUI)
	starter := &testhelpers.FakeAppStarter{}
	stopper := &testhelpers.FakeAppStopper{}
	zipper := &testhelpers.FakeZipper{}
	appRepo := &testhelpers.FakeApplicationRepository{}
	domainRepo := &testhelpers.FakeDomainRepository{}
	routeRepo := &testhelpers.FakeRouteRepository{}
	stackRepo := &testhelpers.FakeStackRepository{}

	cmd := NewPush(fakeUI, starter, stopper, zipper, appRepo, domainRepo, routeRepo, stackRepo)
	ctxt := testhelpers.NewContext("push", []string{})

	reqFactory := &testhelpers.FakeReqFactory{LoginSuccess: true, TargetedSpaceSuccess: true}
	testhelpers.RunCommand(cmd, ctxt, reqFactory)
	assert.True(t, testhelpers.CommandDidPassRequirements)

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

	testhelpers.CommandDidPassRequirements = true

	reqFactory = &testhelpers.FakeReqFactory{LoginSuccess: true, TargetedSpaceSuccess: false}
	testhelpers.RunCommand(cmd, ctxt, reqFactory)
	assert.False(t, testhelpers.CommandDidPassRequirements)
}
예제 #2
0
파일: orgs_test.go 프로젝트: jbayer/cli
func callOrgs(reqFactory *testhelpers.FakeReqFactory, orgRepo *testhelpers.FakeOrgRepository) (fakeUI *testhelpers.FakeUI) {
	fakeUI = &testhelpers.FakeUI{}
	ctxt := testhelpers.NewContext("orgs", []string{})
	cmd := NewListOrganizations(fakeUI, orgRepo)
	testhelpers.RunCommand(cmd, ctxt, reqFactory)
	return
}
예제 #3
0
func callRenameOrg(args []string, reqFactory *testhelpers.FakeReqFactory, orgRepo *testhelpers.FakeOrgRepository) (ui *testhelpers.FakeUI) {
	ui = new(testhelpers.FakeUI)
	ctxt := testhelpers.NewContext("rename-org", args)
	cmd := NewRenameOrg(ui, orgRepo)
	testhelpers.RunCommand(cmd, ctxt, reqFactory)
	return
}
예제 #4
0
파일: logs_test.go 프로젝트: jbayer/cli
func callLogs(args []string, reqFactory *testhelpers.FakeReqFactory, logsRepo *testhelpers.FakeLogsRepository) (ui *testhelpers.FakeUI) {
	ui = new(testhelpers.FakeUI)
	ctxt := testhelpers.NewContext("logs", args)
	cmd := NewLogs(ui, logsRepo)
	testhelpers.RunCommand(cmd, ctxt, reqFactory)
	return
}
예제 #5
0
func callRenameSpace(args []string, reqFactory *testhelpers.FakeReqFactory, spaceRepo *testhelpers.FakeSpaceRepository) (ui *testhelpers.FakeUI) {
	ui = new(testhelpers.FakeUI)
	ctxt := testhelpers.NewContext("create-space", args)
	cmd := NewRenameSpace(ui, spaceRepo)
	testhelpers.RunCommand(cmd, ctxt, reqFactory)
	return
}
예제 #6
0
func callBindService(args []string, reqFactory *testhelpers.FakeReqFactory, serviceRepo api.ServiceRepository) (fakeUI *testhelpers.FakeUI) {
	fakeUI = new(testhelpers.FakeUI)
	ctxt := testhelpers.NewContext("bind-service", args)
	cmd := NewBindService(fakeUI, serviceRepo)
	testhelpers.RunCommand(cmd, ctxt, reqFactory)
	return
}
예제 #7
0
파일: rename_test.go 프로젝트: jbayer/cli
func callRename(args []string, reqFactory *testhelpers.FakeReqFactory, appRepo *testhelpers.FakeApplicationRepository) (ui *testhelpers.FakeUI) {
	ui = new(testhelpers.FakeUI)
	ctxt := testhelpers.NewContext("rename", args)
	cmd := NewRename(ui, appRepo)
	testhelpers.RunCommand(cmd, ctxt, reqFactory)
	return
}
예제 #8
0
func callRecentLogs(args []string, config *configuration.Configuration, reqFactory *testhelpers.FakeReqFactory, appRepo api.ApplicationRepository, logsRepo api.LogsRepository) (ui *testhelpers.FakeUI) {
	ui = new(testhelpers.FakeUI)
	ctxt := testhelpers.NewContext("logs", args)

	cmd := NewRecentLogs(ui, appRepo, logsRepo)
	testhelpers.RunCommand(cmd, ctxt, reqFactory)
	return
}
예제 #9
0
파일: files_test.go 프로젝트: jbayer/cli
func callFiles(args []string, reqFactory *testhelpers.FakeReqFactory, appFilesRepo *testhelpers.FakeAppFilesRepo) (ui *testhelpers.FakeUI) {
	ui = &testhelpers.FakeUI{}
	ctxt := testhelpers.NewContext("files", args)
	cmd := NewFiles(ui, appFilesRepo)
	testhelpers.RunCommand(cmd, ctxt, reqFactory)

	return
}
예제 #10
0
파일: env_test.go 프로젝트: jbayer/cli
func callEnv(args []string, reqFactory *testhelpers.FakeReqFactory) (ui *testhelpers.FakeUI) {
	ui = &testhelpers.FakeUI{}
	ctxt := testhelpers.NewContext("env", args)
	cmd := NewEnv(ui)
	testhelpers.RunCommand(cmd, ctxt, reqFactory)

	return
}
예제 #11
0
func callCreateOrganization(args []string, reqFactory *testhelpers.FakeReqFactory, orgRepo *testhelpers.FakeOrgRepository) (fakeUI *testhelpers.FakeUI) {
	fakeUI = new(testhelpers.FakeUI)
	ctxt := testhelpers.NewContext("create-org", args)
	cmd := NewCreateOrganization(fakeUI, orgRepo)

	testhelpers.RunCommand(cmd, ctxt, reqFactory)
	return
}
예제 #12
0
파일: app_test.go 프로젝트: jbayer/cli
func callApp(args []string, reqFactory *testhelpers.FakeReqFactory, appSummaryRepo *testhelpers.FakeAppSummaryRepo) (ui *testhelpers.FakeUI) {
	ui = &testhelpers.FakeUI{}
	ctxt := testhelpers.NewContext("app", args)
	cmd := NewApp(ui, appSummaryRepo)
	testhelpers.RunCommand(cmd, ctxt, reqFactory)

	return
}
예제 #13
0
func callUnsetEnv(args []string, reqFactory *testhelpers.FakeReqFactory, appRepo api.ApplicationRepository) (ui *testhelpers.FakeUI) {
	ui = new(testhelpers.FakeUI)
	ctxt := testhelpers.NewContext("unset-env", args)

	cmd := NewUnsetEnv(ui, appRepo)
	testhelpers.RunCommand(cmd, ctxt, reqFactory)
	return
}
예제 #14
0
파일: restart_test.go 프로젝트: jbayer/cli
func callRestart(args []string, reqFactory *testhelpers.FakeReqFactory, starter ApplicationStarter, stopper ApplicationStopper) (ui *testhelpers.FakeUI) {
	ui = new(testhelpers.FakeUI)
	ctxt := testhelpers.NewContext("restart", args)

	cmd := NewRestart(ui, starter, stopper)
	testhelpers.RunCommand(cmd, ctxt, reqFactory)
	return
}
예제 #15
0
파일: spaces_test.go 프로젝트: jbayer/cli
func callSpaces(args []string, reqFactory *testhelpers.FakeReqFactory, config *configuration.Configuration, spaceRepo api.SpaceRepository) (ui *testhelpers.FakeUI) {
	ui = new(testhelpers.FakeUI)
	ctxt := testhelpers.NewContext("spaces", args)

	cmd := NewSpaces(ui, config, spaceRepo)
	testhelpers.RunCommand(cmd, ctxt, reqFactory)
	return
}
예제 #16
0
파일: start_test.go 프로젝트: KaiYoung/cli
func callStart(args []string, config *configuration.Configuration, reqFactory *testhelpers.FakeReqFactory, appRepo api.ApplicationRepository) (ui *testhelpers.FakeUI) {
	ui = new(testhelpers.FakeUI)
	ctxt := testhelpers.NewContext("start", args)

	cmd := NewStart(ui, config, appRepo)
	testhelpers.RunCommand(cmd, ctxt, reqFactory)
	return
}
예제 #17
0
파일: stacks_test.go 프로젝트: KaiYoung/cli
func callStacks(stackRepo *testhelpers.FakeStackRepository) (ui *testhelpers.FakeUI) {
	ui = &testhelpers.FakeUI{}

	ctxt := testhelpers.NewContext("stacks", []string{})
	cmd := NewStacks(ui, stackRepo)
	testhelpers.RunCommand(cmd, ctxt, nil)

	return
}
예제 #18
0
파일: password_test.go 프로젝트: jbayer/cli
func callPassword(inputs []string, reqFactory *testhelpers.FakeReqFactory, pwdRepo *testhelpers.FakePasswordRepo, configRepo *testhelpers.FakeConfigRepository) (ui *testhelpers.FakeUI) {
	ui = &testhelpers.FakeUI{Inputs: inputs}

	ctxt := testhelpers.NewContext("passwd", []string{})
	cmd := NewPassword(ui, pwdRepo, configRepo)
	testhelpers.RunCommand(cmd, ctxt, reqFactory)

	return
}
예제 #19
0
파일: api_test.go 프로젝트: jbayer/cli
func callApi(args []string, configRepo configuration.ConfigurationRepository) (ui *testhelpers.FakeUI) {
	ui = new(testhelpers.FakeUI)
	gateway := net.NewCloudControllerGateway(nil)
	cmd := NewApi(ui, gateway, configRepo)
	ctxt := testhelpers.NewContext("api", args)
	reqFactory := &testhelpers.FakeReqFactory{}
	testhelpers.RunCommand(cmd, ctxt, reqFactory)
	return
}
예제 #20
0
func callCreateService(args []string, inputs []string, serviceRepo api.ServiceRepository) (fakeUI *testhelpers.FakeUI) {
	fakeUI = &testhelpers.FakeUI{Inputs: inputs}
	ctxt := testhelpers.NewContext("create-service", args)
	cmd := NewCreateService(fakeUI, serviceRepo)
	reqFactory := &testhelpers.FakeReqFactory{}

	testhelpers.RunCommand(cmd, ctxt, reqFactory)
	return
}
예제 #21
0
파일: apps_test.go 프로젝트: jbayer/cli
func callApps(spaceRepo *testhelpers.FakeSpaceRepository, reqFactory *testhelpers.FakeReqFactory) (ui *testhelpers.FakeUI) {
	ui = &testhelpers.FakeUI{}

	ctxt := testhelpers.NewContext("apps", []string{})
	cmd := NewApps(ui, spaceRepo)
	testhelpers.RunCommand(cmd, ctxt, reqFactory)

	return
}
예제 #22
0
파일: target_test.go 프로젝트: jbayer/cli
func callTarget(args []string, reqFactory *testhelpers.FakeReqFactory,
	configRepo configuration.ConfigurationRepository, orgRepo api.OrganizationRepository,
	spaceRepo api.SpaceRepository) (ui *testhelpers.FakeUI) {

	ui = new(testhelpers.FakeUI)
	cmd := NewTarget(ui, configRepo, orgRepo, spaceRepo)
	ctxt := testhelpers.NewContext("target", args)

	testhelpers.RunCommand(cmd, ctxt, reqFactory)
	return
}
예제 #23
0
파일: delete_test.go 프로젝트: KaiYoung/cli
func deleteApp(confirmation string, args []string) (ui *testhelpers.FakeUI, reqFactory *testhelpers.FakeReqFactory, appRepo *testhelpers.FakeApplicationRepository) {
	app := cf.Application{Name: "app-to-delete", Guid: "app-to-delete-guid"}
	reqFactory = &testhelpers.FakeReqFactory{Application: app}
	appRepo = &testhelpers.FakeApplicationRepository{}
	ui = &testhelpers.FakeUI{
		Inputs: []string{confirmation},
	}
	ctxt := testhelpers.NewContext("delete", args)
	cmd := NewDelete(ui, appRepo)
	testhelpers.RunCommand(cmd, ctxt, reqFactory)
	return
}
예제 #24
0
func deleteSpace(confirmation string, args []string) (ui *testhelpers.FakeUI, reqFactory *testhelpers.FakeReqFactory, spaceRepo *testhelpers.FakeSpaceRepository) {
	space := cf.Space{Name: "space-to-delete", Guid: "space-to-delete-guid"}
	reqFactory = &testhelpers.FakeReqFactory{Space: space}
	spaceRepo = &testhelpers.FakeSpaceRepository{}
	ui = &testhelpers.FakeUI{
		Inputs: []string{confirmation},
	}
	ctxt := testhelpers.NewContext("delete-space", args)
	cmd := NewDeleteSpace(ui, spaceRepo)
	testhelpers.RunCommand(cmd, ctxt, reqFactory)
	return
}
예제 #25
0
func deleteOrganization(confirmation string, args []string) (ui *testhelpers.FakeUI, reqFactory *testhelpers.FakeReqFactory, orgRepo *testhelpers.FakeOrgRepository) {
	org := cf.Organization{Name: "org-to-dellete", Guid: "org-to-delete-guid"}
	reqFactory = &testhelpers.FakeReqFactory{Organization: org}
	orgRepo = &testhelpers.FakeOrgRepository{}
	configRepo := &testhelpers.FakeConfigRepository{}

	ui = &testhelpers.FakeUI{
		Inputs: []string{confirmation},
	}
	ctxt := testhelpers.NewContext("delete-org", args)
	cmd := NewDeleteOrg(ui, orgRepo, configRepo)
	testhelpers.RunCommand(cmd, ctxt, reqFactory)
	return
}
예제 #26
0
파일: push_test.go 프로젝트: KaiYoung/cli
func callPush(args []string,
	starter ApplicationStarter,
	zipper cf.Zipper,
	appRepo api.ApplicationRepository,
	domainRepo api.DomainRepository,
	routeRepo api.RouteRepository,
	stackRepo api.StackRepository) (fakeUI *testhelpers.FakeUI) {

	fakeUI = new(testhelpers.FakeUI)
	ctxt := testhelpers.NewContext("push", args)
	cmd := NewPush(fakeUI, starter, zipper, appRepo, domainRepo, routeRepo, stackRepo)
	reqFactory := &testhelpers.FakeReqFactory{LoginSuccess: true, SpaceSuccess: true}
	testhelpers.RunCommand(cmd, ctxt, reqFactory)

	return
}
예제 #27
0
func TestMarketplaceServices(t *testing.T) {
	serviceOfferings := []cf.ServiceOffering{
		cf.ServiceOffering{
			Label:       "my-service-offering-1",
			Provider:    "my-service-offering-1 provider",
			Description: "service offering 1 description",
			Version:     "1.0",
			Plans: []cf.ServicePlan{
				cf.ServicePlan{Name: "service-plan-a"},
				cf.ServicePlan{Name: "service-plan-b"},
			},
		},
		cf.ServiceOffering{
			Label:       "my-service-offering-2",
			Provider:    "my-service-offering-2 provider",
			Description: "service offering 2 description",
			Version:     "1.4",
			Plans: []cf.ServicePlan{
				cf.ServicePlan{Name: "service-plan-c"},
				cf.ServicePlan{Name: "service-plan-d"},
			},
		},
	}
	serviceRepo := &testhelpers.FakeServiceRepo{ServiceOfferings: serviceOfferings}
	ui := &testhelpers.FakeUI{}

	ctxt := testhelpers.NewContext("services", []string{"--marketplace"})
	reqFactory := &testhelpers.FakeReqFactory{}

	cmd := NewMarketplaceServices(ui, serviceRepo)
	testhelpers.RunCommand(cmd, ctxt, reqFactory)

	assert.Contains(t, ui.Outputs[0], "Getting services from marketplace...")
	assert.Contains(t, ui.Outputs[1], "OK")

	assert.Contains(t, ui.Outputs[3], "my-service-offering-1")
	assert.Contains(t, ui.Outputs[3], "my-service-offering-1 provider")
	assert.Contains(t, ui.Outputs[3], "service offering 1 description")
	assert.Contains(t, ui.Outputs[3], "1.0")
	assert.Contains(t, ui.Outputs[3], "service-plan-a, service-plan-b")

	assert.Contains(t, ui.Outputs[4], "my-service-offering-2")
	assert.Contains(t, ui.Outputs[4], "my-service-offering-2 provider")
	assert.Contains(t, ui.Outputs[4], "service offering 2 description")
	assert.Contains(t, ui.Outputs[4], "1.4")
	assert.Contains(t, ui.Outputs[4], "service-plan-c, service-plan-d")
}
예제 #28
0
파일: delete_test.go 프로젝트: KaiYoung/cli
func TestDeleteWithForceOption(t *testing.T) {
	app := cf.Application{Name: "app-to-delete", Guid: "app-to-delete-guid"}
	reqFactory := &testhelpers.FakeReqFactory{Application: app}
	appRepo := &testhelpers.FakeApplicationRepository{}

	ui := &testhelpers.FakeUI{}
	ctxt := testhelpers.NewContext("delete", []string{"-f", "app-to-delete"})

	cmd := NewDelete(ui, appRepo)
	testhelpers.RunCommand(cmd, ctxt, reqFactory)

	assert.Equal(t, reqFactory.ApplicationName, "app-to-delete")
	assert.Equal(t, len(ui.Prompts), 0)
	assert.Contains(t, ui.Outputs[0], "Deleting app-to-delete")
	assert.Equal(t, appRepo.DeletedApp, reqFactory.Application)
	assert.Contains(t, ui.Outputs[1], "OK")
}
예제 #29
0
func TestDeleteSpaceWithForceOption(t *testing.T) {
	space := cf.Space{Name: "space-to-delete", Guid: "space-to-delete-guid"}
	reqFactory := &testhelpers.FakeReqFactory{Space: space}
	spaceRepo := &testhelpers.FakeSpaceRepository{}

	ui := &testhelpers.FakeUI{}
	ctxt := testhelpers.NewContext("delete", []string{"-f", "space-to-delete"})

	cmd := NewDeleteSpace(ui, spaceRepo)
	testhelpers.RunCommand(cmd, ctxt, reqFactory)

	assert.Equal(t, reqFactory.SpaceName, "space-to-delete")
	assert.Equal(t, len(ui.Prompts), 0)
	assert.Contains(t, ui.Outputs[0], "Deleting")
	assert.Contains(t, ui.Outputs[0], "space-to-delete")
	assert.Equal(t, spaceRepo.DeletedSpace, reqFactory.Space)
	assert.Contains(t, ui.Outputs[1], "OK")
}
예제 #30
0
func TestDeleteOrganizationWithForceOption(t *testing.T) {
	org := cf.Organization{Name: "org-to-delete", Guid: "org-to-delete-guid"}
	reqFactory := &testhelpers.FakeReqFactory{Organization: org}
	orgRepo := &testhelpers.FakeOrgRepository{}
	configRepo := &testhelpers.FakeConfigRepository{}

	ui := &testhelpers.FakeUI{}
	ctxt := testhelpers.NewContext("delete", []string{"-f", "org-to-delete"})

	cmd := NewDeleteOrg(ui, orgRepo, configRepo)
	testhelpers.RunCommand(cmd, ctxt, reqFactory)

	assert.Equal(t, reqFactory.OrganizationName, "org-to-delete")
	assert.Equal(t, len(ui.Prompts), 0)
	assert.Contains(t, ui.Outputs[0], "Deleting")
	assert.Contains(t, ui.Outputs[0], "org-to-delete")
	assert.Equal(t, orgRepo.DeletedOrganization, reqFactory.Organization)
	assert.Contains(t, ui.Outputs[1], "OK")
}