RepUrl:     "http://some-address",
					}, nil)
				})

				Context("when the number of instances decreased", func() {
					var actualLRPGroups []*models.ActualLRPGroup

					BeforeEach(func() {
						actualLRPGroups = []*models.ActualLRPGroup{}
						for i := 4; i >= 0; i-- {
							actualLRPGroups = append(actualLRPGroups, &models.ActualLRPGroup{
								Instance: model_helpers.NewValidActualLRP("some-guid", int32(i)),
							})
						}

						fakeActualLRPDB.ActualLRPGroupsByProcessGuidReturns(actualLRPGroups, nil)
					})

					It("stops extra actual lrps", func() {
						Expect(fakeDesiredLRPDB.DesiredLRPByProcessGuidCallCount()).To(Equal(1))
						_, processGuid := fakeDesiredLRPDB.DesiredLRPByProcessGuidArgsForCall(0)
						Expect(processGuid).To(Equal("some-guid"))

						Expect(fakeServiceClient.CellByIdCallCount()).To(Equal(2))
						Expect(fakeRepClientFactory.CreateClientCallCount()).To(Equal(2))
						repAddr, repURL := fakeRepClientFactory.CreateClientArgsForCall(0)
						Expect(repAddr).To(Equal("some-address"))
						Expect(repURL).To(Equal("http://some-address"))
						repAddr, repURL = fakeRepClientFactory.CreateClientArgsForCall(1)
						Expect(repAddr).To(Equal("some-address"))
						Expect(repURL).To(Equal("http://some-address"))
		JustBeforeEach(func() {
			request := newTestRequest(requestBody)
			handler.ActualLRPGroupsByProcessGuid(logger, responseRecorder, request)
		})

		Context("when reading actual lrps from DB succeeds", func() {
			var actualLRPGroups []*models.ActualLRPGroup

			BeforeEach(func() {
				actualLRPGroups =
					[]*models.ActualLRPGroup{
						{Instance: &actualLRP1},
						{Instance: &actualLRP2, Evacuating: &evacuatingLRP2},
					}
				fakeActualLRPDB.ActualLRPGroupsByProcessGuidReturns(actualLRPGroups, nil)
			})

			It("fetches actual lrp groups by process guid", func() {
				Expect(fakeActualLRPDB.ActualLRPGroupsByProcessGuidCallCount()).To(Equal(1))
				_, actualProcessGuid := fakeActualLRPDB.ActualLRPGroupsByProcessGuidArgsForCall(0)
				Expect(actualProcessGuid).To(Equal(processGuid))
				Expect(responseRecorder.Code).To(Equal(http.StatusOK))
			})

			It("returns a list of actual lrp groups", func() {
				Expect(responseRecorder.Code).To(Equal(http.StatusOK))

				response := &models.ActualLRPGroupsResponse{}
				err := response.Unmarshal(responseRecorder.Body.Bytes())
				Expect(err).NotTo(HaveOccurred())