예제 #1
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
}
예제 #2
0
파일: push_test.go 프로젝트: nsnt/cli
func TestPushingAppWhenItAlreadyExistsAndChangingOptions(t *testing.T) {
	deps := getPushDependencies()

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

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

	deps.appRepo.ReadApp = existingApp

	stack := cf.Stack{}
	stack.Name = "differentStack"
	stack.Guid = "differentStack-guid"
	deps.stackRepo.FindByNameStack = stack

	args := []string{
		"-c", "different start command",
		"-i", "10",
		"-m", "1G",
		"-b", "https://github.com/heroku/heroku-buildpack-different.git",
		"-s", "differentStack",
		"existing-app",
	}
	_ = callPush(t, args, deps)

	assert.Equal(t, deps.appRepo.UpdateParams.Get("command"), "different start command")
	assert.Equal(t, deps.appRepo.UpdateParams.Get("instances"), 10)
	assert.Equal(t, deps.appRepo.UpdateParams.Get("memory"), uint64(1024))
	assert.Equal(t, deps.appRepo.UpdateParams.Get("buildpack"), "https://github.com/heroku/heroku-buildpack-different.git")
	assert.Equal(t, deps.appRepo.UpdateParams.Get("stack_guid"), "differentStack-guid")
}
예제 #3
0
파일: push_test.go 프로젝트: nsnt/cli
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")
}
예제 #4
0
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")
}
예제 #5
0
파일: map_route_test.go 프로젝트: nsnt/cli
func TestMapRouteWhenBinding(t *testing.T) {

	domain := cf.Domain{}
	domain.Guid = "my-domain-guid"
	domain.Name = "example.com"
	route := cf.Route{}
	route.Guid = "my-route-guid"
	route.Host = "foo"
	route.Domain = domain.DomainFields

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

	routeRepo := &testapi.FakeRouteRepository{}
	reqFactory := &testreq.FakeReqFactory{LoginSuccess: true, Application: app, Domain: domain}
	routeCreator := &testcmd.FakeRouteCreator{ReservedRoute: route}

	ui := callMapRoute(t, []string{"-n", "my-host", "my-app", "my-domain.com"}, reqFactory, routeRepo, routeCreator)

	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Adding route", "foo.example.com", "my-app", "my-org", "my-space", "my-user"},
		{"OK"},
	})

	assert.Equal(t, routeRepo.BoundRouteGuid, "my-route-guid")
	assert.Equal(t, routeRepo.BoundAppGuid, "my-app-guid")
}
예제 #6
0
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")
}
예제 #7
0
파일: scale.go 프로젝트: jalateras/cli
func (cmd *Scale) Run(c *cli.Context) {
	currentApp := cmd.appReq.GetApplication()
	cmd.ui.Say("Scaling app %s in org %s / space %s as %s...",
		terminal.EntityNameColor(currentApp.Name),
		terminal.EntityNameColor(cmd.config.Organization.Name),
		terminal.EntityNameColor(cmd.config.Space.Name),
		terminal.EntityNameColor(cmd.config.Username()),
	)

	changedApp := cf.Application{
		Guid: currentApp.Guid,
	}

	memory, err := extractMegaBytes(c.String("m"))
	if err != nil {
		cmd.ui.Say("Invalid value for memory")
		cmd.ui.FailWithUsage(c, "scale")
		return
	}
	changedApp.Memory = memory
	changedApp.Instances = c.Int("i")

	apiResponse := cmd.appRepo.Scale(changedApp)
	if apiResponse.IsNotSuccessful() {
		cmd.ui.Failed(apiResponse.Message)
		return
	}
	cmd.ui.Ok()
	cmd.ui.Say("")
}
예제 #8
0
파일: logs_test.go 프로젝트: nsnt/cli
func TestLogsOutputsRecentLogs(t *testing.T) {
	app := cf.Application{}
	app.Name = "my-app"
	app.Guid = "my-app-guid"

	currentTime := time.Now()

	recentLogs := []*logmessage.Message{
		NewLogMessage("Log Line 1", app.Guid, "DEA", currentTime),
		NewLogMessage("Log Line 2", app.Guid, "DEA", currentTime),
	}

	reqFactory, logsRepo := getLogsDependencies()
	reqFactory.Application = app
	logsRepo.RecentLogs = recentLogs

	ui := callLogs(t, []string{"--recent", "my-app"}, reqFactory, logsRepo)

	assert.Equal(t, reqFactory.ApplicationName, "my-app")
	assert.Equal(t, app.Guid, logsRepo.AppLoggedGuid)
	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Connected, dumping recent logs for app", "my-app", "my-org", "my-space", "my-user"},
		{"Log Line 1"},
		{"Log Line 2"},
	})
}
예제 #9
0
파일: set_env_test.go 프로젝트: nsnt/cli
func TestSetEnvWhenItAlreadyExists(t *testing.T) {
	app := cf.Application{}
	app.Name = "my-app"
	app.Guid = "my-app-guid"
	app.EnvironmentVars = map[string]string{"DATABASE_URL": "mysql://example.com/my-db"}
	reqFactory := &testreq.FakeReqFactory{Application: app, LoginSuccess: true, TargetedSpaceSuccess: true}
	appRepo := &testapi.FakeApplicationRepository{}

	args := []string{"my-app", "DATABASE_URL", "mysql://example2.com/my-db"}
	ui := callSetEnv(t, args, reqFactory, appRepo)

	assert.Equal(t, len(ui.Outputs), 3)
	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{
			"Setting env variable",
			"DATABASE_URL",
			"mysql://example2.com/my-db",
			"my-app",
			"my-org",
			"my-space",
			"my-user",
		},
		{"OK"},
		{"TIP"},
	})

	assert.Equal(t, reqFactory.ApplicationName, "my-app")
	assert.Equal(t, appRepo.UpdateAppGuid, app.Guid)

	envParams := appRepo.UpdateParams.Get("env").(generic.Map)
	assert.Equal(t, envParams.Get("DATABASE_URL").(string), "mysql://example2.com/my-db")
}
예제 #10
0
파일: events_test.go 프로젝트: nsnt/cli
func TestEventsSuccess(t *testing.T) {
	timestamp, err := time.Parse(TIMESTAMP_FORMAT, "2000-01-01T00:01:11.00-0000")
	assert.NoError(t, err)

	reqFactory, eventsRepo := getEventsDependencies()
	app := cf.Application{}
	app.Name = "my-app"
	reqFactory.Application = app

	eventsRepo.Events = []cf.EventFields{
		{
			InstanceIndex:   98,
			Timestamp:       timestamp,
			ExitDescription: "app instance exited",
			ExitStatus:      78,
		},
		{
			InstanceIndex:   99,
			Timestamp:       timestamp,
			ExitDescription: "app instance was stopped",
			ExitStatus:      77,
		},
	}

	ui := callEvents(t, []string{"my-app"}, reqFactory, eventsRepo)

	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Getting events for app", "my-app", "my-org", "my-space", "my-user"},
		{"time", "instance", "description", "exit status"},
		{timestamp.Local().Format(TIMESTAMP_FORMAT), "98", "app instance exited", "78"},
		{timestamp.Local().Format(TIMESTAMP_FORMAT), "99", "app instance was stopped", "77"},
	})
}
예제 #11
0
파일: push_test.go 프로젝트: nsnt/cli
func TestPushingAppWhenItAlreadyExistsAndHostIsSpecified(t *testing.T) {
	deps := getPushDependencies()

	domain := cf.Domain{}
	domain.Name = "example.com"
	domain.Guid = "domain-guid"
	domain.Shared = true

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

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

	deps.appRepo.ReadApp = existingApp
	deps.appRepo.UpdateAppResult = existingApp
	deps.routeRepo.FindByHostAndDomainNotFound = true
	deps.domainRepo.ListSharedDomainsDomains = []cf.Domain{domain}

	ui := callPush(t, []string{"-n", "new-host", "existing-app"}, deps)

	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Creating route", "new-host.example.com"},
		{"OK"},
		{"Binding", "new-host.example.com"},
	})

	assert.Equal(t, deps.routeRepo.FindByHostAndDomainDomain, "example.com")
	assert.Equal(t, deps.routeRepo.FindByHostAndDomainHost, "new-host")
	assert.Equal(t, deps.routeRepo.CreatedHost, "new-host")
	assert.Equal(t, deps.routeRepo.CreatedDomainGuid, "domain-guid")
}
예제 #12
0
파일: push_test.go 프로젝트: nsnt/cli
func TestPushingAppWithNoFlagsWhenAppIsAlreadyBoundToDomain(t *testing.T) {
	deps := getPushDependencies()

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

	existingRoute := cf.RouteSummary{}
	existingRoute.Host = "foo"
	existingRoute.Domain = domain

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

	deps.appRepo.ReadApp = existingApp
	deps.appRepo.UpdateAppResult = existingApp

	_ = callPush(t, []string{"existing-app"}, deps)

	assert.Equal(t, deps.appBitsRepo.UploadedAppGuid, "existing-app-guid")
	assert.Equal(t, deps.domainRepo.FindByNameInCurrentSpaceName, "")
	assert.Equal(t, deps.routeRepo.FindByHostAndDomainDomain, "")
	assert.Equal(t, deps.routeRepo.FindByHostAndDomainHost, "")
	assert.Equal(t, deps.routeRepo.CreatedHost, "")
	assert.Equal(t, deps.routeRepo.CreatedDomainGuid, "")
}
예제 #13
0
파일: restart_test.go 프로젝트: nsnt/cli
func TestRestartApplication(t *testing.T) {
	app := cf.Application{}
	app.Name = "my-app"
	app.Guid = "my-app-guid"
	reqFactory := &testreq.FakeReqFactory{Application: app, LoginSuccess: true, TargetedSpaceSuccess: true}
	starter := &testcmd.FakeAppStarter{}
	stopper := &testcmd.FakeAppStopper{}
	callRestart([]string{"my-app"}, reqFactory, starter, stopper)

	assert.Equal(t, stopper.AppToStop, app)
	assert.Equal(t, starter.AppToStart, app)
}
예제 #14
0
파일: stop_test.go 프로젝트: nsnt/cli
func TestApplicationStopReturnsUpdatedAppWhenAppIsAlreadyStopped(t *testing.T) {
	appToStop := cf.Application{}
	appToStop.Name = "my-app"
	appToStop.Guid = "my-app-guid"
	appToStop.State = "stopped"
	appRepo := &testapi.FakeApplicationRepository{}
	config := &configuration.Configuration{}
	stopper := NewStop(new(testterm.FakeUI), config, appRepo)
	updatedApp, err := stopper.ApplicationStop(appToStop)

	assert.NoError(t, err)
	assert.Equal(t, appToStop, updatedApp)
}
예제 #15
0
파일: stop_test.go 프로젝트: nsnt/cli
func TestStopCommandFailsWithUsage(t *testing.T) {
	app := cf.Application{}
	app.Name = "my-app"
	app.Guid = "my-app-guid"
	appRepo := &testapi.FakeApplicationRepository{ReadApp: app}
	reqFactory := &testreq.FakeReqFactory{Application: app}

	ui := callStop(t, []string{}, reqFactory, appRepo)
	assert.True(t, ui.FailedWithUsage)

	ui = callStop(t, []string{"my-app"}, reqFactory, appRepo)
	assert.False(t, ui.FailedWithUsage)
}
예제 #16
0
파일: events_test.go 프로젝트: nsnt/cli
func TestEventsWhenNoEventsAvailable(t *testing.T) {
	reqFactory, eventsRepo := getEventsDependencies()
	app := cf.Application{}
	app.Name = "my-app"
	reqFactory.Application = app

	ui := callEvents(t, []string{"my-app"}, reqFactory, eventsRepo)

	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"events", "my-app"},
		{"No events", "my-app"},
	})
}
예제 #17
0
파일: show_app_test.go 프로젝트: nsnt/cli
func testDisplayingAppSummaryWithErrorCode(t *testing.T, errorCode string) {
	reqApp := cf.Application{}
	reqApp.Name = "my-app"
	reqApp.Guid = "my-app-guid"

	domain3 := cf.DomainFields{}
	domain3.Name = "example.com"
	domain4 := cf.DomainFields{}
	domain4.Name = "example.com"

	route1 := cf.RouteSummary{}
	route1.Host = "my-app"
	route1.Domain = domain3

	route2 := cf.RouteSummary{}
	route2.Host = "foo"
	route2.Domain = domain4

	routes := []cf.RouteSummary{
		route1,
		route2,
	}

	app := cf.ApplicationFields{}
	app.State = "stopped"
	app.InstanceCount = 2
	app.RunningInstances = 0
	app.Memory = 256

	appSummary := cf.AppSummary{}
	appSummary.ApplicationFields = app
	appSummary.RouteSummaries = routes

	appSummaryRepo := &testapi.FakeAppSummaryRepo{GetSummarySummary: appSummary, GetSummaryErrorCode: errorCode}
	appInstancesRepo := &testapi.FakeAppInstancesRepo{}
	reqFactory := &testreq.FakeReqFactory{LoginSuccess: true, TargetedSpaceSuccess: true, Application: reqApp}
	ui := callApp(t, []string{"my-app"}, reqFactory, appSummaryRepo, appInstancesRepo)

	assert.Equal(t, appSummaryRepo.GetSummaryAppGuid, "my-app-guid")
	assert.Equal(t, appInstancesRepo.GetInstancesAppGuid, "my-app-guid")

	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Showing health and status", "my-app", "my-org", "my-space", "my-user"},
		{"state", "stopped"},
		{"instances", "0/2"},
		{"usage", "256M x 2 instances"},
		{"urls", "my-app.example.com, foo.example.com"},
		{"no running instances"},
	})
}
예제 #18
0
func TestApplicationReqExecute(t *testing.T) {
	app := cf.Application{}
	app.Name = "my-app"
	app.Guid = "my-app-guid"
	appRepo := &testapi.FakeApplicationRepository{ReadApp: app}
	ui := new(testterm.FakeUI)

	appReq := newApplicationRequirement("foo", ui, appRepo)
	success := appReq.Execute()

	assert.True(t, success)
	assert.Equal(t, appRepo.ReadName, "foo")
	assert.Equal(t, appReq.GetApplication(), app)
}
예제 #19
0
파일: files_test.go 프로젝트: nsnt/cli
func TestListingFilesWithTemplateTokens(t *testing.T) {
	app := cf.Application{}
	app.Name = "my-found-app"
	app.Guid = "my-app-guid"

	reqFactory := &testreq.FakeReqFactory{LoginSuccess: true, TargetedSpaceSuccess: true, Application: app}
	appFilesRepo := &testapi.FakeAppFilesRepo{FileList: "%s %d %i"}

	ui := callFiles(t, []string{"my-app", "/foo"}, reqFactory, appFilesRepo)

	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"%s %d %i"},
	})
}
예제 #20
0
func TestCreateApplication(t *testing.T) {
	ts, handler, repo := createAppRepo(t, []testnet.TestRequest{createApplicationRequest})
	defer ts.Close()

	params := defaultAppParams()
	createdApp, apiResponse := repo.Create(params)

	assert.True(t, handler.AllRequestsCalled())
	assert.True(t, apiResponse.IsSuccessful())

	app := cf.Application{}
	app.Name = "my-cool-app"
	app.Guid = "my-cool-app-guid"
	assert.Equal(t, createdApp, app)
}
예제 #21
0
파일: scale_test.go 프로젝트: pmuellr/cli
func TestScaleOnlyMemory(t *testing.T) {
	app := cf.Application{}
	app.Name = "my-app"
	app.Guid = "my-app-guid"
	reqFactory, restarter, appRepo := getScaleDependencies()
	reqFactory.Application = app

	callScale(t, []string{"-m", "512M", "my-app"}, reqFactory, restarter, appRepo)

	assert.Equal(t, appRepo.UpdateAppGuid, "my-app-guid")
	assert.Equal(t, appRepo.UpdateParams.Get("memory").(uint64), uint64(512))

	assert.False(t, appRepo.UpdateParams.Has("disk_quota"))
	assert.False(t, appRepo.UpdateParams.Has("instances"))
}
예제 #22
0
파일: stop_test.go 프로젝트: nsnt/cli
func TestStopApplicationIsAlreadyStopped(t *testing.T) {
	app := cf.Application{}
	app.Name = "my-app"
	app.Guid = "my-app-guid"
	app.State = "stopped"
	appRepo := &testapi.FakeApplicationRepository{ReadApp: app}
	args := []string{"my-app"}
	reqFactory := &testreq.FakeReqFactory{Application: app}
	ui := callStop(t, args, reqFactory, appRepo)

	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"my-app", "is already stopped"},
	})
	assert.Equal(t, appRepo.UpdateAppGuid, "")
}
예제 #23
0
파일: rename_app_test.go 프로젝트: nsnt/cli
func TestRenameRun(t *testing.T) {
	appRepo := &testapi.FakeApplicationRepository{}
	app := cf.Application{}
	app.Name = "my-app"
	app.Guid = "my-app-guid"
	reqFactory := &testreq.FakeReqFactory{LoginSuccess: true, Application: app}
	ui := callRename(t, []string{"my-app", "my-new-app"}, reqFactory, appRepo)

	assert.Equal(t, appRepo.UpdateAppGuid, app.Guid)
	assert.Equal(t, appRepo.UpdateParams.Get("name"), "my-new-app")
	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Renaming app", "my-app", "my-new-app", "my-org", "my-space", "my-user"},
		{"OK"},
	})
}
예제 #24
0
파일: stop_test.go 프로젝트: nsnt/cli
func TestStopApplicationWhenStopFails(t *testing.T) {
	app := cf.Application{}
	app.Name = "my-app"
	app.Guid = "my-app-guid"
	appRepo := &testapi.FakeApplicationRepository{ReadApp: app, UpdateErr: true}
	args := []string{"my-app"}
	reqFactory := &testreq.FakeReqFactory{Application: app}
	ui := callStop(t, args, reqFactory, appRepo)

	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Stopping", "my-app"},
		{"FAILED"},
		{"Error updating app."},
	})
	assert.Equal(t, appRepo.UpdateAppGuid, "my-app-guid")
}
예제 #25
0
파일: stop_test.go 프로젝트: nsnt/cli
func TestStopApplication(t *testing.T) {
	app := cf.Application{}
	app.Name = "my-app"
	app.Guid = "my-app-guid"
	appRepo := &testapi.FakeApplicationRepository{ReadApp: app}
	args := []string{"my-app"}
	reqFactory := &testreq.FakeReqFactory{Application: app}
	ui := callStop(t, args, reqFactory, appRepo)

	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Stopping app", "my-app", "my-org", "my-space", "my-user"},
		{"OK"},
	})

	assert.Equal(t, reqFactory.ApplicationName, "my-app")
	assert.Equal(t, appRepo.UpdateAppGuid, "my-app-guid")
}
예제 #26
0
파일: unset_env_test.go 프로젝트: nsnt/cli
func TestUnsetEnvWhenEnvVarDoesNotExist(t *testing.T) {
	app := cf.Application{}
	app.Name = "my-app"
	app.Guid = "my-app-guid"
	reqFactory := &testreq.FakeReqFactory{Application: app, LoginSuccess: true, TargetedSpaceSuccess: true}
	appRepo := &testapi.FakeApplicationRepository{}

	args := []string{"my-app", "DATABASE_URL"}
	ui := callUnsetEnv(t, args, reqFactory, appRepo)

	assert.Equal(t, len(ui.Outputs), 3)
	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Removing env variable"},
		{"OK"},
		{"DATABASE_URL", "was not set."},
	})
}
예제 #27
0
파일: scale_test.go 프로젝트: pmuellr/cli
func TestScaleAll(t *testing.T) {
	app := cf.Application{}
	app.Name = "my-app"
	app.Guid = "my-app-guid"
	reqFactory, restarter, appRepo := getScaleDependencies()
	reqFactory.Application = app

	ui := callScale(t, []string{"-i", "5", "-m", "512M", "my-app"}, reqFactory, restarter, appRepo)

	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Scaling", "my-app", "my-org", "my-space", "my-user"},
		{"OK"},
	})

	assert.Equal(t, appRepo.UpdateAppGuid, "my-app-guid")
	assert.Equal(t, appRepo.UpdateParams.Get("memory"), uint64(512))
	assert.Equal(t, appRepo.UpdateParams.Get("instances"), 5)
}
예제 #28
0
파일: push_test.go 프로젝트: nsnt/cli
func TestPushingAppToResetStartCommand(t *testing.T) {
	deps := getPushDependencies()

	existingApp := cf.Application{}
	existingApp.Name = "existing-app"
	existingApp.Guid = "existing-app-guid"
	existingApp.Command = "unicorn -c config/unicorn.rb -D"

	deps.appRepo.ReadApp = existingApp

	args := []string{
		"-c", "null",
		"existing-app",
	}
	_ = callPush(t, args, deps)

	assert.Equal(t, deps.appRepo.UpdateParams.Get("command"), "")
}
예제 #29
0
파일: map_route_test.go 프로젝트: nsnt/cli
func TestMapRouteWhenRouteNotReserved(t *testing.T) {
	domain := cf.DomainFields{}
	domain.Name = "my-domain.com"
	route := cf.Route{}
	route.Guid = "my-app-guid"
	route.Host = "my-host"
	route.Domain = domain
	app := cf.Application{}
	app.Guid = "my-app-guid"
	app.Name = "my-app"

	routeRepo := &testapi.FakeRouteRepository{}
	reqFactory := &testreq.FakeReqFactory{LoginSuccess: true, Application: app}
	routeCreator := &testcmd.FakeRouteCreator{ReservedRoute: route}

	callMapRoute(t, []string{"-n", "my-host", "my-app", "my-domain.com"}, reqFactory, routeRepo, routeCreator)

	assert.Equal(t, routeCreator.ReservedRoute, route)
}
예제 #30
0
파일: unset_env_test.go 프로젝트: nsnt/cli
func TestUnsetEnvRequirements(t *testing.T) {
	app := cf.Application{}
	app.Name = "my-app"
	app.Guid = "my-app-guid"
	appRepo := &testapi.FakeApplicationRepository{}
	args := []string{"my-app", "DATABASE_URL"}

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

	reqFactory = &testreq.FakeReqFactory{Application: app, LoginSuccess: false, TargetedSpaceSuccess: true}
	callUnsetEnv(t, args, reqFactory, appRepo)
	assert.False(t, testcmd.CommandDidPassRequirements)

	reqFactory = &testreq.FakeReqFactory{Application: app, LoginSuccess: true, TargetedSpaceSuccess: false}
	callUnsetEnv(t, args, reqFactory, appRepo)
	assert.False(t, testcmd.CommandDidPassRequirements)
}