Skip to content

Instantly share code, notes, and snippets.

@petergtz
Last active April 22, 2018 19:23
Show Gist options
  • Save petergtz/1e800ef11f9bf90dbee2226d6133482c to your computer and use it in GitHub Desktop.
Save petergtz/1e800ef11f9bf90dbee2226d6133482c to your computer and use it in GitHub Desktop.
An example of how to use Pegomock's InOrderContext
// Create mocks:
blobstore := NewMockBlobstore()
updater := NewMockUpdater()
// Create object under test:
handler := NewResourceHandlerWithUpdater(blobstore, updater, ...)
...
// Make request against the Bits-Service resource handler:
handler.AddOrReplace(responseWriter, ..., map[string]string{"identifier": "someguid"})
// Verify the handler's interactions with its collaborators:
inOrder := new(InOrderContext)
updater.VerifyWasCalledInOrder(Once(), inOrder).NotifyProcessingUpload("someguid")
blobstore.VerifyWasCalledInOrder(Once(), inOrder).Put(EqString("someguid"), AnyReadSeeker())
updater.VerifyWasCalledInOrder(Once(), inOrder).NotifyUploadSucceeded("someguid", ...)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment