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"}, }) }
func TestListingRoutes(t *testing.T) { domain := cf.DomainFields{} domain.Name = "example.com" domain2 := cf.DomainFields{} domain2.Name = "cfapps.com" domain3 := cf.DomainFields{} domain3.Name = "another-example.com" app1 := cf.ApplicationFields{} app1.Name = "dora" app2 := cf.ApplicationFields{} app2.Name = "dora2" app3 := cf.ApplicationFields{} app3.Name = "my-app" app4 := cf.ApplicationFields{} app4.Name = "my-app2" app5 := cf.ApplicationFields{} app5.Name = "july" route := cf.Route{} route.Host = "hostname-1" route.Domain = domain route.Apps = []cf.ApplicationFields{app1, app2} route2 := cf.Route{} route2.Host = "hostname-2" route2.Domain = domain2 route2.Apps = []cf.ApplicationFields{app3, app4} route3 := cf.Route{} route3.Host = "hostname-3" route3.Domain = domain3 route3.Apps = []cf.ApplicationFields{app5} routes := []cf.Route{route, route2, route3} routeRepo := &testapi.FakeRouteRepository{Routes: routes} ui := callListRoutes(t, []string{}, &testreq.FakeReqFactory{}, routeRepo) testassert.SliceContains(t, ui.Outputs, testassert.Lines{ {"Getting routes", "my-user"}, {"host", "domain", "apps"}, {"hostname-1", "example.com", "dora", "dora2"}, {"hostname-2", "cfapps.com", "my-app", "my-app2"}, {"hostname-3", "another-example.com", "july"}, }) }
func TestShowSpaceInfoSuccess(t *testing.T) { org := cf.OrganizationFields{} org.Name = "my-org" app := cf.ApplicationFields{} app.Name = "app1" app.Guid = "app1-guid" apps := []cf.ApplicationFields{app} domain := cf.DomainFields{} domain.Name = "domain1" domain.Guid = "domain1-guid" domains := []cf.DomainFields{domain} serviceInstance := cf.ServiceInstanceFields{} serviceInstance.Name = "service1" serviceInstance.Guid = "service1-guid" services := []cf.ServiceInstanceFields{serviceInstance} space := cf.Space{} space.Name = "space1" space.Organization = org space.Applications = apps space.Domains = domains space.ServiceInstances = services reqFactory := &testreq.FakeReqFactory{LoginSuccess: true, TargetedOrgSuccess: true, Space: space} ui := callShowSpace(t, []string{"space1"}, reqFactory) testassert.SliceContains(t, ui.Outputs, testassert.Lines{ {"Getting info for space", "space1", "my-org", "my-user"}, {"OK"}, {"space1"}, {"Org", "my-org"}, {"Apps", "app1"}, {"Domains", "domain1"}, {"Services", "service1"}, }) }