Esempio n. 1
0
func TestApplicationStopReturnsUpdatedApp(t *testing.T) {
	appToStop := cf.Application{}
	appToStop.Name = "my-app"
	appToStop.Guid = "my-app-guid"
	appToStop.State = "started"
	expectedStoppedApp := cf.Application{}
	expectedStoppedApp.Name = "my-stopped-app"
	expectedStoppedApp.Guid = "my-stopped-app-guid"
	expectedStoppedApp.State = "stopped"

	appRepo := &testapi.FakeApplicationRepository{UpdateAppResult: expectedStoppedApp}
	config := &configuration.Configuration{}
	stopper := NewStop(new(testterm.FakeUI), config, appRepo)
	actualStoppedApp, err := stopper.ApplicationStop(appToStop)

	assert.NoError(t, err)
	assert.Equal(t, expectedStoppedApp, actualStoppedApp)
}
Esempio n. 2
0
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)
}
Esempio n. 3
0
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, "")
}
Esempio n. 4
0
func TestUpdateApplication(t *testing.T) {
	ts, handler, repo := createAppRepo(t, []testnet.TestRequest{updateApplicationRequest})
	defer ts.Close()

	app := cf.Application{}
	app.Guid = "my-app-guid"
	app.Name = "my-cool-app"
	app.BuildpackUrl = "buildpack-url"
	app.Command = "some-command"
	app.Memory = 2048
	app.InstanceCount = 3
	app.Stack.Guid = "some-stack-guid"
	app.SpaceGuid = "some-space-guid"
	app.State = "started"

	updatedApp, apiResponse := repo.Update(app.Guid, app.ToParams())

	assert.True(t, handler.AllRequestsCalled())
	assert.True(t, apiResponse.IsSuccessful())
	assert.Equal(t, updatedApp.Name, "my-cool-app")
	assert.Equal(t, updatedApp.Guid, "my-cool-app-guid")
}
Esempio n. 5
0
func TestStartApplicationIsAlreadyStarted(t *testing.T) {
	t.Parallel()

	displayApp := &testcmd.FakeAppDisplayer{}
	config := &configuration.Configuration{}
	app := cf.Application{}
	app.Name = "my-app"
	app.Guid = "my-app-guid"
	app.State = "started"
	appRepo := &testapi.FakeApplicationRepository{ReadApp: app}
	appInstancesRepo := &testapi.FakeAppInstancesRepo{}
	logRepo := &testapi.FakeLogsRepository{}

	reqFactory := &testreq.FakeReqFactory{Application: app}

	args := []string{"my-app"}
	ui := callStart(args, config, reqFactory, displayApp, appRepo, appInstancesRepo, logRepo)

	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"my-app", "is already started"},
	})

	assert.Equal(t, appRepo.UpdateAppGuid, "")
}