Пример #1
0
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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")
}