{"action":"created","comment":{"url":"https://api.github.com/repos/miekg/dns/pulls/comments/54331918","id":54331918,"diff_hunk":"@@ -83,3 +84,60 @@ func TestRemoveRRset(t *testing.T) {\n \t\tt.Errorf(\"actual msg:\\n%v\", tmp)\n \t}\n }\n+\n+func TestPreReqAndRemovals(t *testing.T) {\n+\t// Build a list of multiple prereqs and then somes removes followed by an insert.\n+\t// We should be able to add multiple prereqs and updates.\n+\tm := new(Msg)\n+\tm.SetUpdate(\"some_zone.\")\n+\tm.Id = 1234\n+\n+\t// Use a full set of RRs each time, so we are sure the rdata is stripped.\n+\trr_name1, _ := NewRR(\"name_used. 3600 IN A 127.0.0.1\")\n+\trr_name2, _ := NewRR(\"name_not_used. 3600 IN A 127.0.0.1\")\n+\trr_remove1, _ := NewRR(\"remove1. 3600 IN A 127.0.0.1\")\n+\trr_remove2, _ := NewRR(\"remove2. 3600 IN A 127.0.0.1\")\n+\trr_remove3, _ := NewRR(\"remove3. 3600 IN A 127.0.0.1\")\n+\trr_insert, _ := NewRR(\"insert. 3600 IN A 127.0.0.1\")\n+\trr_rrset1, _ := NewRR(\"rrset_used1. 3600 IN A 127.0.0.1\")\n+\trr_rrset2, _ := NewRR(\"rrset_used2. 3600 IN A 127.0.0.1\")\n+\trr_rrset3, _ := NewRR(\"rrset_not_used. 3600 IN A 127.0.0.1\")\n+\n+\t// Handle the prereqs.\n+\tm.NameUsed([]RR{rr_name1})\n+\tm.NameNotUsed([]RR{rr_name2})\n+\tm.RRsetUsed([]RR{rr_rrset1})\n+\tm.Used([]RR{rr_rrset2})\n+\tm.RRsetNotUsed([]RR{rr_rrset3})\n+\n+\t// and now the updates.\n+\tm.RemoveName([]RR{rr_remove1})\n+\tm.RemoveRRset([]RR{rr_remove2})\n+\tm.Remove([]RR{rr_remove3})\n+\tm.Insert([]RR{rr_insert})\n+\n+\texpect := `;; opcode: UPDATE, status: NOERROR, id: 1234","path":"update_test.go","position":44,"original_position":44,"commit_id":"a6971e606dd0b413479d25bf2d1a6f42cb9e568b","original_commit_id":"a6971e606dd0b413479d25bf2d1a6f42cb9e568b","user":{"login":"miekg","id":353371,"avatar_url":"https://avatars.githubusercontent.com/u/353371?v=3","gravatar_id":"","url":"https://api.github.com/users/miekg","html_url":"https://github.com/miekg","followers_url":"https://api.github.com/users/miekg/followers","following_url":"https://api.github.com/users/miekg/following{/other_user}","gists_url":"https://api.github.com/users/miekg/gists{/gist_id}","starred_url":"https://api.github.com/users/miekg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/miekg/subscriptions","organizations_url":"https://api.github.com/users/miekg/orgs","repos_url":"https://api.github.com/users/miekg/repos","events_url":"https://api.github.com/users/miekg/events{/privacy}","received_events_url":"https://api.github.com/users/miekg/received_events","type":"User","site_admin":false},"body":"If we want to do a check like this it's better to write an Example test.","created_at":"2016-02-27T10:54:44Z","updated_at":"2016-02-27T10:54:44Z","html_url":"https://github.com/miekg/dns/pull/319#discussion_r54331918","pull_request_url":"https://api.github.com/repos/miekg/dns/pulls/319","_links":{"self":{"href":"https://api.github.com/repos/miekg/dns/pulls/comments/54331918"},"html":{"href":"https://github.com/miekg/dns/pull/319#discussion_r54331918"},"pull_request":{"href":"https://api.github.com/repos/miekg/dns/pulls/319"}}},"pull_request":{"url":"https://api.github.com/repos/miekg/dns/pulls/319","id":60946086,"html_url":"https://github.com/miekg/dns/pull/319","diff_url":"https://github.com/miekg/dns/pull/319.diff","patch_url":"https://github.com/miekg/dns/pull/319.patch","issue_url":"https://api.github.com/repos/miekg/dns/issues/319","number":319,"state":"open","locked":false,"title":"Fix code around dynamic updates, allowing for multiple prereq/inserts/removals per update","user":{"login":"middelink","id":10226229,"avatar_url":"https://avatars.githubusercontent.com/u/10226229?v=3","gravatar_id":"","url":"https://api.github.com/users/middelink","html_url":"https://github.com/middelink","followers_url":"https://api.github.com/users/middelink/followers","following_url":"https://api.github.com/users/middelink/following{/other_user}","gists_url":"https://api.github.com/users/middelink/gists{/gist_id}","starred_url":"https://api.github.com/users/middelink/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/middelink/subscriptions","organizations_url":"https://api.github.com/users/middelink/orgs","repos_url":"https://api.github.com/users/middelink/repos","events_url":"https://api.github.com/users/middelink/events{/privacy}","received_events_url":"https://api.github.com/users/middelink/received_events","type":"User","site_admin":false},"body":"An update msg can have multiple, different prerequests and also multiple, different remove and inserts. The old code did a reset of the ANSWER and AUTHORITY section each time a rrset was added.\r\n\r\nMade a slight optimization that the first time an rrset is added, we\r\ntake it length as the initial size. Helps for the one-time add cases.\r\n\r\nAdded test to prevent regressions.","created_at":"2016-02-27T10:48:34Z","updated_at":"2016-02-27T10:54:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6ad3385fb0380f0b2120e4c2304abfe84bc62d62","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/miekg/dns/pulls/319/commits","review_comments_url":"https://api.github.com/repos/miekg/dns/pulls/319/comments","review_comment_url":"https://api.github.com/repos/miekg/dns/pulls/comments{/number}","comments_url":"https://api.github.com/repos/miekg/dns/issues/319/comments","statuses_url":"https://api.github.com/repos/miekg/dns/statuses/a6971e606dd0b413479d25bf2d1a6f42cb9e568b","head":{"label":"middelink:dynupdates","ref":"dynupdates","sha":"a6971e606dd0b413479d25bf2d1a6f42cb9e568b","user":{"login":"middelink","id":10226229,"avatar_url":"https://avatars.githubusercontent.com/u/10226229?v=3","gravatar_id":"","url":"https://api.github.com/users/middelink","html_url":"https://github.com/middelink","followers_url":"https://api.github.com/users/middelink/followers","following_url":"https://api.github.com/users/middelink/following{/other_user}","gists_url":"https://api.github.com/users/middelink/gists{/gist_id}","starred_url":"https://api.github.com/users/middelink/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/middelink/subscriptions","organizations_url":"https://api.github.com/users/middelink/orgs","repos_url":"https://api.github.com/users/middelink/repos","events_url":"https://api.github.com/users/middelink/events{/privacy}","received_events_url":"https://api.github.com/users/middelink/received_events","type":"User","site_admin":false},"repo":{"id":52660926,"name":"dns","full_name":"middelink/dns","owner":{"login":"middelink","id":10226229,"avatar_url":"https://avatars.githubusercontent.com/u/10226229?v=3","gravatar_id":"","url":"https://api.github.com/users/middelink","html_url":"https://github.com/middelink","followers_url":"https://api.github.com/users/middelink/followers","following_url":"https://api.github.com/users/middelink/following{/other_user}","gists_url":"https://api.github.com/users/middelink/gists{/gist_id}","starred_url":"https://api.github.com/users/middelink/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/middelink/subscriptions","organizations_url":"https://api.github.com/users/middelink/orgs","repos_url":"https://api.github.com/users/middelink/repos","events_url":"https://api.github.com/users/middelink/events{/privacy}","received_events_url":"https://api.github.com/users/middelink/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/middelink/dns","description":"DNS library in Go","fork":true,"url":"https://api.github.com/repos/middelink/dns","forks_url":"https://api.github.com/repos/middelink/dns/forks","keys_url":"https://api.github.com/repos/middelink/dns/keys{/key_id}","collaborators_url":"https://api.github.com/repos/middelink/dns/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/middelink/dns/teams","hooks_url":"https://api.github.com/repos/middelink/dns/hooks","issue_events_url":"https://api.github.com/repos/middelink/dns/issues/events{/number}","events_url":"https://api.github.com/repos/middelink/dns/events","assignees_url":"https://api.github.com/repos/middelink/dns/assignees{/user}","branches_url":"https://api.github.com/repos/middelink/dns/branches{/branch}","tags_url":"https://api.github.com/repos/middelink/dns/tags","blobs_url":"https://api.github.com/repos/middelink/dns/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/middelink/dns/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/middelink/dns/git/refs{/sha}","trees_url":"https://api.github.com/repos/middelink/dns/git/trees{/sha}","statuses_url":"https://api.github.com/repos/middelink/dns/statuses/{sha}","languages_url":"https://api.github.com/repos/middelink/dns/languages","stargazers_url":"https://api.github.com/repos/middelink/dns/stargazers","contributors_url":"https://api.github.com/repos/middelink/dns/contributors","subscribers_url":"https://api.github.com/repos/middelink/dns/subscribers","subscription_url":"https://api.github.com/repos/middelink/dns/subscription","commits_url":"https://api.github.com/repos/middelink/dns/commits{/sha}","git_commits_url":"https://api.github.com/repos/middelink/dns/git/commits{/sha}","comments_url":"https://api.github.com/repos/middelink/dns/comments{/number}","issue_comment_url":"https://api.github.com/repos/middelink/dns/issues/comments{/number}","contents_url":"https://api.github.com/repos/middelink/dns/contents/{+path}","compare_url":"https://api.github.com/repos/middelink/dns/compare/{base}...{head}","merges_url":"https://api.github.com/repos/middelink/dns/merges","archive_url":"https://api.github.com/repos/middelink/dns/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/middelink/dns/downloads","issues_url":"https://api.github.com/repos/middelink/dns/issues{/number}","pulls_url":"https://api.github.com/repos/middelink/dns/pulls{/number}","milestones_url":"https://api.github.com/repos/middelink/dns/milestones{/number}","notifications_url":"https://api.github.com/repos/middelink/dns/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/middelink/dns/labels{/name}","releases_url":"https://api.github.com/repos/middelink/dns/releases{/id}","deployments_url":"https://api.github.com/repos/middelink/dns/deployments","created_at":"2016-02-27T10:11:07Z","updated_at":"2016-02-27T10:11:08Z","pushed_at":"2016-02-27T10:46:06Z","git_url":"git://github.com/middelink/dns.git","ssh_url":"git@github.com:middelink/dns.git","clone_url":"https://github.com/middelink/dns.git","svn_url":"https://github.com/middelink/dns","homepage":"https://miek.nl/2014/August/16/go-dns-package","size":10598,"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":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"miekg:master","ref":"master","sha":"905106d0e8908efdda8d4519c817622c7e8ee8ec","user":{"login":"miekg","id":353371,"avatar_url":"https://avatars.githubusercontent.com/u/353371?v=3","gravatar_id":"","url":"https://api.github.com/users/miekg","html_url":"https://github.com/miekg","followers_url":"https://api.github.com/users/miekg/followers","following_url":"https://api.github.com/users/miekg/following{/other_user}","gists_url":"https://api.github.com/users/miekg/gists{/gist_id}","starred_url":"https://api.github.com/users/miekg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/miekg/subscriptions","organizations_url":"https://api.github.com/users/miekg/orgs","repos_url":"https://api.github.com/users/miekg/repos","events_url":"https://api.github.com/users/miekg/events{/privacy}","received_events_url":"https://api.github.com/users/miekg/received_events","type":"User","site_admin":false},"repo":{"id":815644,"name":"dns","full_name":"miekg/dns","owner":{"login":"miekg","id":353371,"avatar_url":"https://avatars.githubusercontent.com/u/353371?v=3","gravatar_id":"","url":"https://api.github.com/users/miekg","html_url":"https://github.com/miekg","followers_url":"https://api.github.com/users/miekg/followers","following_url":"https://api.github.com/users/miekg/following{/other_user}","gists_url":"https://api.github.com/users/miekg/gists{/gist_id}","starred_url":"https://api.github.com/users/miekg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/miekg/subscriptions","organizations_url":"https://api.github.com/users/miekg/orgs","repos_url":"https://api.github.com/users/miekg/repos","events_url":"https://api.github.com/users/miekg/events{/privacy}","received_events_url":"https://api.github.com/users/miekg/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/miekg/dns","description":"DNS library in Go","fork":false,"url":"https://api.github.com/repos/miekg/dns","forks_url":"https://api.github.com/repos/miekg/dns/forks","keys_url":"https://api.github.com/repos/miekg/dns/keys{/key_id}","collaborators_url":"https://api.github.com/repos/miekg/dns/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/miekg/dns/teams","hooks_url":"https://api.github.com/repos/miekg/dns/hooks","issue_events_url":"https://api.github.com/repos/miekg/dns/issues/events{/number}","events_url":"https://api.github.com/repos/miekg/dns/events","assignees_url":"https://api.github.com/repos/miekg/dns/assignees{/user}","branches_url":"https://api.github.com/repos/miekg/dns/branches{/branch}","tags_url":"https://api.github.com/repos/miekg/dns/tags","blobs_url":"https://api.github.com/repos/miekg/dns/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/miekg/dns/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/miekg/dns/git/refs{/sha}","trees_url":"https://api.github.com/repos/miekg/dns/git/trees{/sha}","statuses_url":"https://api.github.com/repos/miekg/dns/statuses/{sha}","languages_url":"https://api.github.com/repos/miekg/dns/languages","stargazers_url":"https://api.github.com/repos/miekg/dns/stargazers","contributors_url":"https://api.github.com/repos/miekg/dns/contributors","subscribers_url":"https://api.github.com/repos/miekg/dns/subscribers","subscription_url":"https://api.github.com/repos/miekg/dns/subscription","commits_url":"https://api.github.com/repos/miekg/dns/commits{/sha}","git_commits_url":"https://api.github.com/repos/miekg/dns/git/commits{/sha}","comments_url":"https://api.github.com/repos/miekg/dns/comments{/number}","issue_comment_url":"https://api.github.com/repos/miekg/dns/issues/comments{/number}","contents_url":"https://api.github.com/repos/miekg/dns/contents/{+path}","compare_url":"https://api.github.com/repos/miekg/dns/compare/{base}...{head}","merges_url":"https://api.github.com/repos/miekg/dns/merges","archive_url":"https://api.github.com/repos/miekg/dns/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/miekg/dns/downloads","issues_url":"https://api.github.com/repos/miekg/dns/issues{/number}","pulls_url":"https://api.github.com/repos/miekg/dns/pulls{/number}","milestones_url":"https://api.github.com/repos/miekg/dns/milestones{/number}","notifications_url":"https://api.github.com/repos/miekg/dns/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/miekg/dns/labels{/name}","releases_url":"https://api.github.com/repos/miekg/dns/releases{/id}","deployments_url":"https://api.github.com/repos/miekg/dns/deployments","created_at":"2010-08-03T21:56:23Z","updated_at":"2016-02-27T10:11:01Z","pushed_at":"2016-02-27T10:51:17Z","git_url":"git://github.com/miekg/dns.git","ssh_url":"git@github.com:miekg/dns.git","clone_url":"https://github.com/miekg/dns.git","svn_url":"https://github.com/miekg/dns","homepage":"https://miek.nl/2014/August/16/go-dns-package","size":12143,"stargazers_count":1367,"watchers_count":1367,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":242,"mirror_url":null,"open_issues_count":13,"forks":242,"open_issues":13,"watchers":1367,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/miekg/dns/pulls/319"},"html":{"href":"https://github.com/miekg/dns/pull/319"},"issue":{"href":"https://api.github.com/repos/miekg/dns/issues/319"},"comments":{"href":"https://api.github.com/repos/miekg/dns/issues/319/comments"},"review_comments":{"href":"https://api.github.com/repos/miekg/dns/pulls/319/comments"},"review_comment":{"href":"https://api.github.com/repos/miekg/dns/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/miekg/dns/pulls/319/commits"},"statuses":{"href":"https://api.github.com/repos/miekg/dns/statuses/a6971e606dd0b413479d25bf2d1a6f42cb9e568b"}}}}