Exemplo n.º 1
0
func TestPushingAppWhenItDoesNotExist(t *testing.T) {
	deps := getPushDependencies()

	domain := cf.Domain{}
	domain.Guid = "not-the-right-guid"
	domain.Name = "not shared domain"
	domain.OwningOrganizationGuid = "my-org-guid"

	sharedDomain := cf.Domain{}
	sharedDomain.Name = "foo.cf-app.com"
	sharedDomain.Shared = true
	sharedDomain.Guid = "foo-domain-guid"
	appRepo := deps.appRepo
	domainRepo := deps.domainRepo
	routeRepo := deps.routeRepo
	appBitsRepo := deps.appBitsRepo
	stopper := deps.stopper
	starter := deps.starter

	domainRepo.ListDomainsForOrgDomains = []cf.Domain{domain, sharedDomain}
	routeRepo.FindByHostAndDomainErr = true

	appRepo.ReadNotFound = true

	ui := callPush(t, []string{"-t", "111", "my-new-app"}, deps)
	assert.Equal(t, appRepo.CreatedAppParams().Get("name").(string), "my-new-app")
	assert.Equal(t, appRepo.CreatedAppParams().Get("space_guid").(string), "my-space-guid")

	assert.Equal(t, routeRepo.FindByHostAndDomainHost, "my-new-app")
	assert.Equal(t, routeRepo.CreatedHost, "my-new-app")
	assert.Equal(t, routeRepo.CreatedDomainGuid, "foo-domain-guid")
	assert.Equal(t, routeRepo.BoundAppGuid, "my-new-app-guid")
	assert.Equal(t, routeRepo.BoundRouteGuid, "my-new-app-route-guid")

	assert.Equal(t, appBitsRepo.UploadedAppGuid, "my-new-app-guid")

	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Creating app", "my-new-app", "my-org", "my-space"},
		{"OK"},
		{"Creating", "my-new-app.foo.cf-app.com"},
		{"OK"},
		{"Binding", "my-new-app.foo.cf-app.com"},
		{"OK"},
		{"Uploading my-new-app"},
		{"OK"},
	})

	assert.Equal(t, stopper.AppToStop.Guid, "")
	assert.Equal(t, starter.AppToStart.Guid, "my-new-app-guid")
	assert.Equal(t, starter.AppToStart.Name, "my-new-app")
	assert.Equal(t, starter.Timeout, 111)
}