{"action":"created","comment":{"url":"https://api.github.com/repos/Shopify/sarama/pulls/comments/36520660","id":36520660,"diff_hunk":"@@ -230,3 +230,152 @@ func (mfr *mockFetchResponse) getHighWaterMark(topic string, partition int32) in\n \t}\n \treturn partitions[partition]\n }\n+\n+// mockConsumerMetadataResponse is a `ConsumerMetadataResponse` builder.\n+type mockConsumerMetadataResponse struct {\n+\tcoordinators map[string]interface{}\n+\tt            *testing.T\n+}\n+\n+func newMockConsumerMetadataResponse(t *testing.T) *mockConsumerMetadataResponse {\n+\treturn &mockConsumerMetadataResponse{\n+\t\tcoordinators: make(map[string]interface{}),\n+\t\tt:            t,\n+\t}\n+}\n+\n+func (mr *mockConsumerMetadataResponse) SetCoordinator(group string, broker *mockBroker) *mockConsumerMetadataResponse {\n+\tmr.coordinators[group] = broker\n+\treturn mr\n+}\n+\n+func (mr *mockConsumerMetadataResponse) SetError(group string, kerror KError) *mockConsumerMetadataResponse {\n+\tmr.coordinators[group] = kerror\n+\treturn mr\n+}\n+\n+func (mr *mockConsumerMetadataResponse) For(reqBody decoder) encoder {\n+\treq := reqBody.(*ConsumerMetadataRequest)\n+\tgroup := req.ConsumerGroup\n+\tres := &ConsumerMetadataResponse{}\n+\tv := mr.coordinators[group]\n+\tswitch v := v.(type) {\n+\tcase *mockBroker:\n+\t\tres.Coordinator = &Broker{id: v.BrokerID(), addr: v.Addr()}\n+\tcase KError:\n+\t\tres.Err = v\n+\t}\n+\treturn res\n+}\n+\n+// mockOffsetCommitResponse is a `OffsetCommitResponse` builder.\n+type mockOffsetCommitResponse struct {\n+\terrors map[string]map[string]map[int32]KError\n+\tt      *testing.T\n+}\n+\n+func newMockOffsetCommitResponse(t *testing.T) *mockOffsetCommitResponse {\n+\treturn &mockOffsetCommitResponse{t: t}\n+}\n+\n+func (mr *mockOffsetCommitResponse) SetError(group, topic string, partition int32, kerror KError) *mockOffsetCommitResponse {\n+\tif mr.errors == nil {\n+\t\tmr.errors = make(map[string]map[string]map[int32]KError)\n+\t}\n+\ttopics := mr.errors[group]\n+\tif topics == nil {\n+\t\ttopics = make(map[string]map[int32]KError)\n+\t\tmr.errors[group] = topics\n+\t}\n+\tpartitions := topics[topic]\n+\tif partitions == nil {\n+\t\tpartitions = make(map[int32]KError)\n+\t\ttopics[topic] = partitions\n+\t}\n+\tpartitions[partition] = kerror\n+\treturn mr\n+}\n+\n+func (mr *mockOffsetCommitResponse) For(reqBody decoder) encoder {\n+\treq := reqBody.(*OffsetCommitRequest)\n+\tgroup := req.ConsumerGroup\n+\tres := &OffsetCommitResponse{}\n+\tfor topic, partitions := range req.blocks {\n+\t\tfor partition := range partitions {\n+\t\t\tres.AddError(topic, partition, mr.getError(group, topic, partition))\n+\t\t}\n+\t}\n+\treturn res\n+}\n+\n+func (mr *mockOffsetCommitResponse) getError(group, topic string, partition int32) KError {\n+\ttopics := mr.errors[group]\n+\tif topics == nil {\n+\t\treturn ErrNoError\n+\t}\n+\tpartitions := topics[topic]\n+\tif partitions == nil {\n+\t\treturn ErrNoError\n+\t}\n+\tkerror, ok := partitions[partition]\n+\tif !ok {\n+\t\treturn ErrNoError\n+\t}\n+\treturn kerror\n+}\n+\n+// mockOffsetFetchResponse is a `OffsetFetchResponse` builder.\n+type mockOffsetFetchResponse struct {\n+\toffsets map[string]map[string]map[int32]*OffsetFetchResponseBlock\n+\tt       *testing.T\n+}\n+\n+func newMockOffsetFetchResponse(t *testing.T) *mockOffsetFetchResponse {\n+\treturn &mockOffsetFetchResponse{t: t}\n+}\n+\n+func (mr *mockOffsetFetchResponse) SetOffset(group, topic string, partition int32, offset int64, metadata string, kerror KError) *mockOffsetFetchResponse {\n+\tif mr.offsets == nil {\n+\t\tmr.offsets = make(map[string]map[string]map[int32]*OffsetFetchResponseBlock)\n+\t}\n+\ttopics := mr.offsets[group]\n+\tif topics == nil {\n+\t\ttopics = make(map[string]map[int32]*OffsetFetchResponseBlock)\n+\t\tmr.offsets[group] = topics\n+\t}\n+\tpartitions := topics[topic]\n+\tif partitions == nil {\n+\t\tpartitions = make(map[int32]*OffsetFetchResponseBlock)\n+\t\ttopics[topic] = partitions\n+\t}\n+\tpartitions[partition] = &OffsetFetchResponseBlock{offset, metadata, kerror}\n+\treturn mr\n+}\n+\n+func (mr *mockOffsetFetchResponse) For(reqBody decoder) encoder {\n+\treq := reqBody.(*OffsetFetchRequest)\n+\tgroup := req.ConsumerGroup\n+\tres := &OffsetFetchResponse{}\n+\tfor topic, partitions := range mr.offsets[group] {\n+\t\tfor partition, block := range partitions {\n+\t\t\tres.AddBlock(topic, partition, block)\n+\t\t}\n+\t}\n+\treturn res\n+}\n+\n+//func (mr *mockOffsetFetchResponse) getOffset(group, topic string, partition int32) *OffsetFetchResponseBlock {","path":"mockresponses_test.go","position":138,"original_position":138,"commit_id":"b5c2de04009efb4454e96fd4732e5d24f05586d6","original_commit_id":"b5c2de04009efb4454e96fd4732e5d24f05586d6","user":{"login":"eapache","id":1706826,"avatar_url":"https://avatars.githubusercontent.com/u/1706826?v=3","gravatar_id":"","url":"https://api.github.com/users/eapache","html_url":"https://github.com/eapache","followers_url":"https://api.github.com/users/eapache/followers","following_url":"https://api.github.com/users/eapache/following{/other_user}","gists_url":"https://api.github.com/users/eapache/gists{/gist_id}","starred_url":"https://api.github.com/users/eapache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eapache/subscriptions","organizations_url":"https://api.github.com/users/eapache/orgs","repos_url":"https://api.github.com/users/eapache/repos","events_url":"https://api.github.com/users/eapache/events{/privacy}","received_events_url":"https://api.github.com/users/eapache/received_events","type":"User","site_admin":false},"body":"why is this commented out?","created_at":"2015-08-07T13:56:36Z","updated_at":"2015-08-07T13:56:36Z","html_url":"https://github.com/Shopify/sarama/pull/503#discussion_r36520660","pull_request_url":"https://api.github.com/repos/Shopify/sarama/pulls/503","_links":{"self":{"href":"https://api.github.com/repos/Shopify/sarama/pulls/comments/36520660"},"html":{"href":"https://github.com/Shopify/sarama/pull/503#discussion_r36520660"},"pull_request":{"href":"https://api.github.com/repos/Shopify/sarama/pulls/503"}}},"pull_request":{"url":"https://api.github.com/repos/Shopify/sarama/pulls/503","id":41861256,"html_url":"https://github.com/Shopify/sarama/pull/503","diff_url":"https://github.com/Shopify/sarama/pull/503.diff","patch_url":"https://github.com/Shopify/sarama/pull/503.patch","issue_url":"https://api.github.com/repos/Shopify/sarama/issues/503","number":503,"state":"open","locked":false,"title":"Add mock responses for OffsetManager testing","user":{"login":"horkhe","id":798874,"avatar_url":"https://avatars.githubusercontent.com/u/798874?v=3","gravatar_id":"","url":"https://api.github.com/users/horkhe","html_url":"https://github.com/horkhe","followers_url":"https://api.github.com/users/horkhe/followers","following_url":"https://api.github.com/users/horkhe/following{/other_user}","gists_url":"https://api.github.com/users/horkhe/gists{/gist_id}","starred_url":"https://api.github.com/users/horkhe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/horkhe/subscriptions","organizations_url":"https://api.github.com/users/horkhe/orgs","repos_url":"https://api.github.com/users/horkhe/repos","events_url":"https://api.github.com/users/horkhe/events{/privacy}","received_events_url":"https://api.github.com/users/horkhe/received_events","type":"User","site_admin":false},"body":"This PR brings mock response builders and respective additions to response structs that are used by offset manager.","created_at":"2015-08-07T05:42:18Z","updated_at":"2015-08-07T13:56:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e7e7b7597d11cbf00f6197af319eec0d95c9dd8d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Shopify/sarama/pulls/503/commits","review_comments_url":"https://api.github.com/repos/Shopify/sarama/pulls/503/comments","review_comment_url":"https://api.github.com/repos/Shopify/sarama/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Shopify/sarama/issues/503/comments","statuses_url":"https://api.github.com/repos/Shopify/sarama/statuses/b5c2de04009efb4454e96fd4732e5d24f05586d6","head":{"label":"mailgun:maxim/moremocks","ref":"maxim/moremocks","sha":"b5c2de04009efb4454e96fd4732e5d24f05586d6","user":{"login":"mailgun","id":447686,"avatar_url":"https://avatars.githubusercontent.com/u/447686?v=3","gravatar_id":"","url":"https://api.github.com/users/mailgun","html_url":"https://github.com/mailgun","followers_url":"https://api.github.com/users/mailgun/followers","following_url":"https://api.github.com/users/mailgun/following{/other_user}","gists_url":"https://api.github.com/users/mailgun/gists{/gist_id}","starred_url":"https://api.github.com/users/mailgun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mailgun/subscriptions","organizations_url":"https://api.github.com/users/mailgun/orgs","repos_url":"https://api.github.com/users/mailgun/repos","events_url":"https://api.github.com/users/mailgun/events{/privacy}","received_events_url":"https://api.github.com/users/mailgun/received_events","type":"Organization","site_admin":false},"repo":{"id":37499059,"name":"sarama","full_name":"mailgun/sarama","owner":{"login":"mailgun","id":447686,"avatar_url":"https://avatars.githubusercontent.com/u/447686?v=3","gravatar_id":"","url":"https://api.github.com/users/mailgun","html_url":"https://github.com/mailgun","followers_url":"https://api.github.com/users/mailgun/followers","following_url":"https://api.github.com/users/mailgun/following{/other_user}","gists_url":"https://api.github.com/users/mailgun/gists{/gist_id}","starred_url":"https://api.github.com/users/mailgun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mailgun/subscriptions","organizations_url":"https://api.github.com/users/mailgun/orgs","repos_url":"https://api.github.com/users/mailgun/repos","events_url":"https://api.github.com/users/mailgun/events{/privacy}","received_events_url":"https://api.github.com/users/mailgun/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mailgun/sarama","description":"Sarama is a Go library for Apache Kafka 0.8 ","fork":true,"url":"https://api.github.com/repos/mailgun/sarama","forks_url":"https://api.github.com/repos/mailgun/sarama/forks","keys_url":"https://api.github.com/repos/mailgun/sarama/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mailgun/sarama/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mailgun/sarama/teams","hooks_url":"https://api.github.com/repos/mailgun/sarama/hooks","issue_events_url":"https://api.github.com/repos/mailgun/sarama/issues/events{/number}","events_url":"https://api.github.com/repos/mailgun/sarama/events","assignees_url":"https://api.github.com/repos/mailgun/sarama/assignees{/user}","branches_url":"https://api.github.com/repos/mailgun/sarama/branches{/branch}","tags_url":"https://api.github.com/repos/mailgun/sarama/tags","blobs_url":"https://api.github.com/repos/mailgun/sarama/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mailgun/sarama/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mailgun/sarama/git/refs{/sha}","trees_url":"https://api.github.com/repos/mailgun/sarama/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mailgun/sarama/statuses/{sha}","languages_url":"https://api.github.com/repos/mailgun/sarama/languages","stargazers_url":"https://api.github.com/repos/mailgun/sarama/stargazers","contributors_url":"https://api.github.com/repos/mailgun/sarama/contributors","subscribers_url":"https://api.github.com/repos/mailgun/sarama/subscribers","subscription_url":"https://api.github.com/repos/mailgun/sarama/subscription","commits_url":"https://api.github.com/repos/mailgun/sarama/commits{/sha}","git_commits_url":"https://api.github.com/repos/mailgun/sarama/git/commits{/sha}","comments_url":"https://api.github.com/repos/mailgun/sarama/comments{/number}","issue_comment_url":"https://api.github.com/repos/mailgun/sarama/issues/comments{/number}","contents_url":"https://api.github.com/repos/mailgun/sarama/contents/{+path}","compare_url":"https://api.github.com/repos/mailgun/sarama/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mailgun/sarama/merges","archive_url":"https://api.github.com/repos/mailgun/sarama/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mailgun/sarama/downloads","issues_url":"https://api.github.com/repos/mailgun/sarama/issues{/number}","pulls_url":"https://api.github.com/repos/mailgun/sarama/pulls{/number}","milestones_url":"https://api.github.com/repos/mailgun/sarama/milestones{/number}","notifications_url":"https://api.github.com/repos/mailgun/sarama/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mailgun/sarama/labels{/name}","releases_url":"https://api.github.com/repos/mailgun/sarama/releases{/id}","created_at":"2015-06-16T00:40:36Z","updated_at":"2015-06-16T00:40:36Z","pushed_at":"2015-08-07T05:50:47Z","git_url":"git://github.com/mailgun/sarama.git","ssh_url":"git@github.com:mailgun/sarama.git","clone_url":"https://github.com/mailgun/sarama.git","svn_url":"https://github.com/mailgun/sarama","homepage":"http://shopify.github.io/sarama","size":1461,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"Shopify:master","ref":"master","sha":"3ef4815458b77ef8b74523ad582ee4946f66a5a9","user":{"login":"Shopify","id":8085,"avatar_url":"https://avatars.githubusercontent.com/u/8085?v=3","gravatar_id":"","url":"https://api.github.com/users/Shopify","html_url":"https://github.com/Shopify","followers_url":"https://api.github.com/users/Shopify/followers","following_url":"https://api.github.com/users/Shopify/following{/other_user}","gists_url":"https://api.github.com/users/Shopify/gists{/gist_id}","starred_url":"https://api.github.com/users/Shopify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shopify/subscriptions","organizations_url":"https://api.github.com/users/Shopify/orgs","repos_url":"https://api.github.com/users/Shopify/repos","events_url":"https://api.github.com/users/Shopify/events{/privacy}","received_events_url":"https://api.github.com/users/Shopify/received_events","type":"Organization","site_admin":false},"repo":{"id":11206255,"name":"sarama","full_name":"Shopify/sarama","owner":{"login":"Shopify","id":8085,"avatar_url":"https://avatars.githubusercontent.com/u/8085?v=3","gravatar_id":"","url":"https://api.github.com/users/Shopify","html_url":"https://github.com/Shopify","followers_url":"https://api.github.com/users/Shopify/followers","following_url":"https://api.github.com/users/Shopify/following{/other_user}","gists_url":"https://api.github.com/users/Shopify/gists{/gist_id}","starred_url":"https://api.github.com/users/Shopify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shopify/subscriptions","organizations_url":"https://api.github.com/users/Shopify/orgs","repos_url":"https://api.github.com/users/Shopify/repos","events_url":"https://api.github.com/users/Shopify/events{/privacy}","received_events_url":"https://api.github.com/users/Shopify/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Shopify/sarama","description":"Sarama is a Go library for Apache Kafka 0.8 ","fork":false,"url":"https://api.github.com/repos/Shopify/sarama","forks_url":"https://api.github.com/repos/Shopify/sarama/forks","keys_url":"https://api.github.com/repos/Shopify/sarama/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Shopify/sarama/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Shopify/sarama/teams","hooks_url":"https://api.github.com/repos/Shopify/sarama/hooks","issue_events_url":"https://api.github.com/repos/Shopify/sarama/issues/events{/number}","events_url":"https://api.github.com/repos/Shopify/sarama/events","assignees_url":"https://api.github.com/repos/Shopify/sarama/assignees{/user}","branches_url":"https://api.github.com/repos/Shopify/sarama/branches{/branch}","tags_url":"https://api.github.com/repos/Shopify/sarama/tags","blobs_url":"https://api.github.com/repos/Shopify/sarama/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Shopify/sarama/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Shopify/sarama/git/refs{/sha}","trees_url":"https://api.github.com/repos/Shopify/sarama/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Shopify/sarama/statuses/{sha}","languages_url":"https://api.github.com/repos/Shopify/sarama/languages","stargazers_url":"https://api.github.com/repos/Shopify/sarama/stargazers","contributors_url":"https://api.github.com/repos/Shopify/sarama/contributors","subscribers_url":"https://api.github.com/repos/Shopify/sarama/subscribers","subscription_url":"https://api.github.com/repos/Shopify/sarama/subscription","commits_url":"https://api.github.com/repos/Shopify/sarama/commits{/sha}","git_commits_url":"https://api.github.com/repos/Shopify/sarama/git/commits{/sha}","comments_url":"https://api.github.com/repos/Shopify/sarama/comments{/number}","issue_comment_url":"https://api.github.com/repos/Shopify/sarama/issues/comments{/number}","contents_url":"https://api.github.com/repos/Shopify/sarama/contents/{+path}","compare_url":"https://api.github.com/repos/Shopify/sarama/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Shopify/sarama/merges","archive_url":"https://api.github.com/repos/Shopify/sarama/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Shopify/sarama/downloads","issues_url":"https://api.github.com/repos/Shopify/sarama/issues{/number}","pulls_url":"https://api.github.com/repos/Shopify/sarama/pulls{/number}","milestones_url":"https://api.github.com/repos/Shopify/sarama/milestones{/number}","notifications_url":"https://api.github.com/repos/Shopify/sarama/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Shopify/sarama/labels{/name}","releases_url":"https://api.github.com/repos/Shopify/sarama/releases{/id}","created_at":"2013-07-05T18:52:38Z","updated_at":"2015-08-06T23:22:55Z","pushed_at":"2015-08-07T05:50:47Z","git_url":"git://github.com/Shopify/sarama.git","ssh_url":"git@github.com:Shopify/sarama.git","clone_url":"https://github.com/Shopify/sarama.git","svn_url":"https://github.com/Shopify/sarama","homepage":"http://shopify.github.io/sarama","size":5942,"stargazers_count":575,"watchers_count":575,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":108,"mirror_url":null,"open_issues_count":24,"forks":108,"open_issues":24,"watchers":575,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Shopify/sarama/pulls/503"},"html":{"href":"https://github.com/Shopify/sarama/pull/503"},"issue":{"href":"https://api.github.com/repos/Shopify/sarama/issues/503"},"comments":{"href":"https://api.github.com/repos/Shopify/sarama/issues/503/comments"},"review_comments":{"href":"https://api.github.com/repos/Shopify/sarama/pulls/503/comments"},"review_comment":{"href":"https://api.github.com/repos/Shopify/sarama/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Shopify/sarama/pulls/503/commits"},"statuses":{"href":"https://api.github.com/repos/Shopify/sarama/statuses/b5c2de04009efb4454e96fd4732e5d24f05586d6"}}}}