Last active
October 17, 2016 20:17
-
-
Save csmith0651/f674268eb807f201459803d7822f38d0 to your computer and use it in GitHub Desktop.
example of registering a mock call on the mock object.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Context("ReadPersonFromS3 -- using mock", func() { | |
bucket := "testbucket" | |
key := "persondata.txt" | |
objectInput := &s3.GetObjectInput{ | |
Bucket: aws.String(bucket), | |
Key: aws.String(key), | |
} | |
goodObjectOutput := &s3.GetObjectOutput{ | |
Body: S3Fetcher.NewMockBody([]byte(goodJson)), | |
} | |
BeforeEach(func() { | |
mockFetcher = mock_S3Fetcher.NewMockS3Fetcher(ctrl) | |
}) | |
Context("reads data from S3", func() { | |
var testCall *gomock.Call | |
BeforeEach(func() { | |
testCall = mockFetcher.EXPECT().GetObject(objectInput).Return(goodObjectOutput, nil).AnyTimes() | |
}) | |
It("and succeeds", func() { | |
Expect(ReadPersonFromS3(mockFetcher)).To(HaveLen(2)) | |
testCall.Times(1) | |
}) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment