本文整理匯總了Golang中code/cloudfoundry/org/bbs/events/eventfakes.FakeHub.EmitArgsForCall方法的典型用法代碼示例。如果您正苦於以下問題:Golang FakeHub.EmitArgsForCall方法的具體用法?Golang FakeHub.EmitArgsForCall怎麽用?Golang FakeHub.EmitArgsForCall使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類code/cloudfoundry/org/bbs/events/eventfakes.FakeHub
的用法示例。
在下文中一共展示了FakeHub.EmitArgsForCall方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
It("unclaims and auctions the actual lrps with missing cells", func() {
Eventually(fakeLRPDB.UnclaimActualLRPCallCount).Should(Equal(2))
unclaimedKeys := []*models.ActualLRPKey{}
for i := 0; i < fakeLRPDB.UnclaimActualLRPCallCount(); i++ {
_, key := fakeLRPDB.UnclaimActualLRPArgsForCall(i)
unclaimedKeys = append(unclaimedKeys, key)
}
Expect(unclaimedKeys).To(ContainElement(&unclaimingActualLRP1.ActualLRPKey))
Expect(unclaimedKeys).To(ContainElement(&unclaimingActualLRP2.ActualLRPKey))
Eventually(actualHub.EmitCallCount).Should(Equal(2))
changeEvents := []*models.ActualLRPChangedEvent{}
for i := 0; i < actualHub.EmitCallCount(); i++ {
event := actualHub.EmitArgsForCall(i)
if changeEvent, ok := event.(*models.ActualLRPChangedEvent); ok {
changeEvents = append(changeEvents, changeEvent)
}
}
group1 := &models.ActualLRPGroup{Instance: unclaimingActualLRP1}
group2 := &models.ActualLRPGroup{Instance: unclaimingActualLRP2}
Expect(changeEvents).To(ContainElement(models.NewActualLRPChangedEvent(group1, group1)))
Expect(changeEvents).To(ContainElement(models.NewActualLRPChangedEvent(group2, group2)))
})
Context("when the DB returns an unrecoverable error", func() {
BeforeEach(func() {
fakeLRPDB.UnclaimActualLRPReturns(nil, nil, models.NewUnrecoverableError(nil))
})
示例2:
Expect(err).NotTo(HaveOccurred())
Expect(response.Error).To(BeNil())
})
It("claims the actual lrp by process guid and index", func() {
Expect(fakeActualLRPDB.ClaimActualLRPCallCount()).To(Equal(1))
_, actualProcessGuid, actualIndex, actualInstanceKey := fakeActualLRPDB.ClaimActualLRPArgsForCall(0)
Expect(actualProcessGuid).To(Equal(processGuid))
Expect(actualIndex).To(BeEquivalentTo(index))
Expect(*actualInstanceKey).To(Equal(instanceKey))
})
It("emits a change event to the hub", func() {
Eventually(actualHub.EmitCallCount).Should(Equal(1))
event := actualHub.EmitArgsForCall(0)
changedEvent, ok := event.(*models.ActualLRPChangedEvent)
Expect(ok).To(BeTrue())
Expect(changedEvent.Before).To(Equal(&models.ActualLRPGroup{Instance: &actualLRP}))
Expect(changedEvent.After).To(Equal(&models.ActualLRPGroup{Instance: &afterActualLRP}))
})
Context("when the actual lrp did not actually change", func() {
BeforeEach(func() {
fakeActualLRPDB.ClaimActualLRPReturns(
&models.ActualLRPGroup{Instance: &afterActualLRP},
&models.ActualLRPGroup{Instance: &afterActualLRP},
nil,
)
})
示例3:
It("creates desired lrp", func() {
Expect(fakeDesiredLRPDB.DesireLRPCallCount()).To(Equal(1))
_, actualDesiredLRP := fakeDesiredLRPDB.DesireLRPArgsForCall(0)
Expect(actualDesiredLRP).To(Equal(desiredLRP))
Expect(responseRecorder.Code).To(Equal(http.StatusOK))
response := models.DesiredLRPLifecycleResponse{}
err := response.Unmarshal(responseRecorder.Body.Bytes())
Expect(err).NotTo(HaveOccurred())
Expect(response.Error).To(BeNil())
})
It("emits a create event to the hub", func() {
Eventually(desiredHub.EmitCallCount).Should(Equal(1))
event := desiredHub.EmitArgsForCall(0)
createEvent, ok := event.(*models.DesiredLRPCreatedEvent)
Expect(ok).To(BeTrue())
Expect(createEvent.DesiredLrp).To(Equal(desiredLRP))
})
It("creates and emits an event for one ActualLRP per index", func() {
Expect(fakeActualLRPDB.CreateUnclaimedActualLRPCallCount()).To(Equal(5))
Eventually(actualHub.EmitCallCount).Should(Equal(5))
expectedLRPKeys := []*models.ActualLRPKey{}
for i := 0; i < 5; i++ {
expectedLRPKeys = append(expectedLRPKeys, &models.ActualLRPKey{
ProcessGuid: desiredLRP.ProcessGuid,
Domain: desiredLRP.Domain,
示例4:
BeforeEach(func() {
fakeEvacuationDB.RemoveEvacuatingActualLRPReturns(nil)
})
It("removeEvacuatings the actual lrp by process guid and index", func() {
Expect(responseRecorder.Code).To(Equal(http.StatusOK))
Expect(fakeEvacuationDB.RemoveEvacuatingActualLRPCallCount()).To(Equal(1))
_, actualKey, actualInstanceKey := fakeEvacuationDB.RemoveEvacuatingActualLRPArgsForCall(0)
Expect(*actualKey).To(Equal(key))
Expect(*actualInstanceKey).To(Equal(instanceKey))
})
It("emits events to the hub", func() {
Eventually(actualHub.EmitCallCount).Should(Equal(1))
event := actualHub.EmitArgsForCall(0)
removeEvent, ok := event.(*models.ActualLRPRemovedEvent)
Expect(ok).To(BeTrue())
Expect(removeEvent.ActualLrpGroup).To(Equal(&models.ActualLRPGroup{Evacuating: actual}))
})
})
Context("when the request is invalid", func() {
BeforeEach(func() {
requestBody = &models.RemoveEvacuatingActualLRPRequest{}
})
It("responds with an error", func() {
Expect(responseRecorder.Code).To(Equal(http.StatusOK))
var response models.RemoveEvacuatingActualLRPResponse