func TestCreateRouteIsIdempotent(t *testing.T) { space := cf.SpaceFields{} space.Guid = "my-space-guid" space.Name = "my-space" domain := cf.DomainFields{} domain.Guid = "domain-guid" domain.Name = "example.com" reqFactory := &testreq.FakeReqFactory{ LoginSuccess: true, TargetedOrgSuccess: true, Domain: cf.Domain{DomainFields: domain}, Space: cf.Space{SpaceFields: space}, } route := cf.Route{} route.Guid = "my-route-guid" route.Host = "host" route.Domain = domain route.Space = space routeRepo := &testapi.FakeRouteRepository{ CreateInSpaceErr: true, FindByHostAndDomainRoute: route, } ui := callCreateRoute(t, []string{"-n", "host", "my-space", "example.com"}, reqFactory, routeRepo) testassert.SliceContains(t, ui.Outputs, testassert.Lines{ {"Creating route"}, {"OK"}, {"host.example.com", "already exists"}, }) assert.Equal(t, routeRepo.CreateInSpaceHost, "host") assert.Equal(t, routeRepo.CreateInSpaceDomainGuid, "domain-guid") assert.Equal(t, routeRepo.CreateInSpaceSpaceGuid, "my-space-guid") }