Skip to content

Instantly share code, notes, and snippets.

@csmith0651
Created October 18, 2016 12:15
Show Gist options
  • Save csmith0651/dad4a1559808f26546c9e78cf7a32ade to your computer and use it in GitHub Desktop.
Save csmith0651/dad4a1559808f26546c9e78cf7a32ade to your computer and use it in GitHub Desktop.
prime a mock call to return an error and test for it
Context("simulate an error retrieving data from S3", func() {
var testCall *gomock.Call
BeforeEach(func() {
testCall = mockFetcher.EXPECT().GetObject(gomock.Any()).Return(nil, fmt.Errorf("AWS error")).AnyTimes()
})
It("and fails", func() {
_, err := ReadPersonFromS3(mockFetcher)
Expect(err).To(HaveOccurred())
testCall.Times(1)
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment