func TestPushingAppWithCustomFlags(t *testing.T) { deps := getPushDependencies() domain := cf.Domain{} domain.Name = "bar.cf-app.com" domain.Guid = "bar-domain-guid" stack := cf.Stack{} stack.Name = "customLinux" stack.Guid = "custom-linux-guid" deps.domainRepo.FindByNameDomain = domain deps.routeRepo.FindByHostAndDomainErr = true deps.stackRepo.FindByNameStack = stack deps.appRepo.ReadNotFound = true ui := callPush(t, []string{ "-c", "unicorn -c config/unicorn.rb -D", "-d", "bar.cf-app.com", "-n", "my-hostname", "-i", "3", "-m", "2G", "-b", "https://github.com/heroku/heroku-buildpack-play.git", "-s", "customLinux", "-t", "1", "--no-start", "my-new-app", }, deps) testassert.SliceContains(t, ui.Outputs, testassert.Lines{ {"Using", "customLinux"}, {"OK"}, {"Creating app", "my-new-app"}, {"OK"}, {"Creating Route", "my-hostname.bar.cf-app.com"}, {"OK"}, {"Binding", "my-hostname.bar.cf-app.com", "my-new-app"}, {"Uploading", "my-new-app"}, {"OK"}, }) assert.Equal(t, deps.stackRepo.FindByNameName, "customLinux") assert.Equal(t, deps.appRepo.CreatedAppParams().Get("name").(string), "my-new-app") assert.Equal(t, deps.appRepo.CreatedAppParams().Get("command").(string), "unicorn -c config/unicorn.rb -D") assert.Equal(t, deps.appRepo.CreatedAppParams().Get("instances").(int), 3) assert.Equal(t, deps.appRepo.CreatedAppParams().Get("memory").(uint64), uint64(2048)) assert.Equal(t, deps.appRepo.CreatedAppParams().Get("stack_guid"), "custom-linux-guid") assert.Equal(t, deps.appRepo.CreatedAppParams().Get("health_check_timeout").(int), 1) assert.Equal(t, deps.appRepo.CreatedAppParams().Get("buildpack"), "https://github.com/heroku/heroku-buildpack-play.git") assert.Equal(t, deps.domainRepo.FindByNameInCurrentSpaceName, "bar.cf-app.com") assert.Equal(t, deps.routeRepo.CreatedHost, "my-hostname") assert.Equal(t, deps.routeRepo.CreatedDomainGuid, "bar-domain-guid") assert.Equal(t, deps.routeRepo.BoundAppGuid, "my-new-app-guid") assert.Equal(t, deps.routeRepo.BoundRouteGuid, "my-hostname-route-guid") assert.Equal(t, deps.appBitsRepo.UploadedAppGuid, "my-new-app-guid") assert.Equal(t, deps.starter.AppToStart.Name, "") }
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") }
func TestStacks(t *testing.T) { stack1 := cf.Stack{} stack1.Name = "Stack-1" stack1.Description = "Stack 1 Description" stack2 := cf.Stack{} stack2.Name = "Stack-2" stack2.Description = "Stack 2 Description" stackRepo := &testapi.FakeStackRepository{ FindAllStacks: []cf.Stack{stack1, stack2}, } ui := callStacks(t, stackRepo) assert.Equal(t, len(ui.Outputs), 6) testassert.SliceContains(t, ui.Outputs, testassert.Lines{ {"Getting stacks in org", "my-org", "my-space", "my-user"}, {"OK"}, {"Stack-1", "Stack 1 Description"}, {"Stack-2", "Stack 2 Description"}, }) }