{"action":"created","comment":{"url":"https://api.github.com/repos/juju/juju/pulls/comments/24881277","id":24881277,"diff_hunk":"@@ -0,0 +1,299 @@\n+// Copyright 2015 Canonical Ltd.\n+// Licensed under the AGPLv3, see LICENCE file for details.\n+\n+package params_test\n+\n+import (\n+\t\"encoding/json\"\n+\n+\tjc \"github.com/juju/testing/checkers\"\n+\tgc \"gopkg.in/check.v1\"\n+\n+\t\"github.com/juju/juju/apiserver/params\"\n+\t\"github.com/juju/juju/network\"\n+)\n+\n+type (\n+\tP struct {\n+\t\tprot string\n+\t\tnum  int\n+\t}\n+\tIS []interface{}\n+\tM  map[string]interface{}\n+)\n+\n+type NetworkSuite struct{}\n+\n+var _ = gc.Suite(&NetworkSuite{})\n+\n+func (s *NetworkSuite) TestPortsResults(c *gc.C) {\n+\t// Convenience helpers.\n+\tmkPortsResults := func(prs ...params.PortsResult) params.PortsResults {\n+\t\treturn params.PortsResults{\n+\t\t\tResults: prs,\n+\t\t}\n+\t}\n+\tmkPortsResult := func(msg, code string, ports ...P) params.PortsResult {\n+\t\tpr := params.PortsResult{}\n+\t\tif msg != \"\" {\n+\t\t\tpr.Error = &params.Error{msg, code}\n+\t\t}\n+\t\tfor _, p := range ports {\n+\t\t\tpr.Ports = append(pr.Ports, params.Port{p.prot, p.num})\n+\t\t}\n+\t\treturn pr\n+\t}\n+\tmkResults := func(rs ...interface{}) M {\n+\t\treturn M{\"Results\": rs}\n+\t}\n+\tmkResult := func(err, ports interface{}) M {\n+\t\treturn M{\"Error\": err, \"Ports\": ports}\n+\t}\n+\tmkError := func(msg, code string) M {\n+\t\treturn M{\"Message\": msg, \"Code\": code}\n+\t}\n+\tmkPort := func(prot string, num int) M {\n+\t\treturn M{\"Protocol\": prot, \"Number\": num}\n+\t}\n+\t// Tests.\n+\ttests := []struct {","path":"apiserver/params/network_test.go","position":59,"original_position":59,"commit_id":"1bdebafcc9f3e5fcb3bf3ce529e92ca0e0d7c509","original_commit_id":"1bdebafcc9f3e5fcb3bf3ce529e92ca0e0d7c509","user":{"login":"dimitern","id":619986,"avatar_url":"https://avatars.githubusercontent.com/u/619986?v=3","gravatar_id":"","url":"https://api.github.com/users/dimitern","html_url":"https://github.com/dimitern","followers_url":"https://api.github.com/users/dimitern/followers","following_url":"https://api.github.com/users/dimitern/following{/other_user}","gists_url":"https://api.github.com/users/dimitern/gists{/gist_id}","starred_url":"https://api.github.com/users/dimitern/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dimitern/subscriptions","organizations_url":"https://api.github.com/users/dimitern/orgs","repos_url":"https://api.github.com/users/dimitern/repos","events_url":"https://api.github.com/users/dimitern/events{/privacy}","received_events_url":"https://api.github.com/users/dimitern/received_events","type":"User","site_admin":false},"body":"How about indentation like this:\r\n\r\n```go\r\ntests := []struct {\r\n    about string\r\n    results params.PortsResults\r\n    expected M\r\n}{{\r\n    about: \"empty result set\",\r\n    results: mkPortsResults(),\r\n    expected: mkResults(),\r\n}, {\r\n    about: \"one error\",\r\n    results: mkPortsResults(mkPortsResult(\r\n        \"I failed\", \"ERR42\"),\r\n    ),\r\n    expected: mkResults(mkResult(\r\n        mkError(\"I failed\", \"ERR42\"),\r\n        nil,\r\n    )),\r\n}, {\r\n    about: \"one succes with one port\",\r\n    results: mkPortsResults(\r\n        mkPortsResult(\"\", \"\", P{\"tcp\", 80}),\r\n    ),\r\n    expected: mkResults(mkResult(\r\n        nil,\r\n        IS{mkPort(\"tcp\", 80)}),\r\n    ),\r\n}, {\r\n    about: \"two results, one error and one success with two ports\",\r\n    results: mkPortsResults(\r\n        mkPortsResult(\"I failed\", \"ERR42\"),\r\n        mkPortsResult(\"\", \"\", P{\"tcp\", 80}, P{\"tcp\", 443}),\r\n    ),\r\n    expected: mkResults(\r\n        mkResult(mkError(\"I failed\", \"ERR42\"), nil),\r\n        mkResult(\r\n            nil,\r\n            IS{mkPort(\"tcp\", 80), mkPort(\"tcp\", 443)},\r\n        ),\r\n    ),\r\n}}\r\n```","created_at":"2015-02-18T06:25:03Z","updated_at":"2015-02-18T06:25:03Z","html_url":"https://github.com/juju/juju/pull/1617#discussion_r24881277","pull_request_url":"https://api.github.com/repos/juju/juju/pulls/1617","_links":{"self":{"href":"https://api.github.com/repos/juju/juju/pulls/comments/24881277"},"html":{"href":"https://github.com/juju/juju/pull/1617#discussion_r24881277"},"pull_request":{"href":"https://api.github.com/repos/juju/juju/pulls/1617"}}},"pull_request":{"url":"https://api.github.com/repos/juju/juju/pulls/1617","id":29473664,"html_url":"https://github.com/juju/juju/pull/1617","diff_url":"https://github.com/juju/juju/pull/1617.diff","patch_url":"https://github.com/juju/juju/pull/1617.patch","issue_url":"https://api.github.com/repos/juju/juju/issues/1617","number":1617,"state":"open","locked":false,"title":"Cleanup of network parameters","user":{"login":"TheMue","id":1633981,"avatar_url":"https://avatars.githubusercontent.com/u/1633981?v=3","gravatar_id":"","url":"https://api.github.com/users/TheMue","html_url":"https://github.com/TheMue","followers_url":"https://api.github.com/users/TheMue/followers","following_url":"https://api.github.com/users/TheMue/following{/other_user}","gists_url":"https://api.github.com/users/TheMue/gists{/gist_id}","starred_url":"https://api.github.com/users/TheMue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheMue/subscriptions","organizations_url":"https://api.github.com/users/TheMue/orgs","repos_url":"https://api.github.com/users/TheMue/repos","events_url":"https://api.github.com/users/TheMue/events{/privacy}","received_events_url":"https://api.github.com/users/TheMue/received_events","type":"User","site_admin":false},"body":"The package `apiserver/params` currently contains direct field references to the `networking` package. A cleaner separation is wanted, so the types are now duplicated inside `params` and contain convenience functions and methods to convert from and to `networking`. Those are now used where needed.\r\n\r\nAdditionally all networking related code is now in a file `network.go`, the tests in the file `network_test.go`. Here the old tests didn't checked the correct marshalling. This has be changed too.\r\n\r\nAs third step the type `NetworkInfo` is now renamed into `NetworkConfig`. Depending functions, fields, types inside the API are renamed too. Others have to be renamed in a following change, otherwise this grows too much.\n\n(Review request: http://reviews.vapour.ws/r/947/)","created_at":"2015-02-17T20:14:35Z","updated_at":"2015-02-18T06:25:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"96cb0890dd738803094a32ec127a7e71a06f3b76","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/juju/juju/pulls/1617/commits","review_comments_url":"https://api.github.com/repos/juju/juju/pulls/1617/comments","review_comment_url":"https://api.github.com/repos/juju/juju/pulls/comments/{number}","comments_url":"https://api.github.com/repos/juju/juju/issues/1617/comments","statuses_url":"https://api.github.com/repos/juju/juju/statuses/1bdebafcc9f3e5fcb3bf3ce529e92ca0e0d7c509","head":{"label":"TheMue:networking-cleanup-params","ref":"networking-cleanup-params","sha":"1bdebafcc9f3e5fcb3bf3ce529e92ca0e0d7c509","user":{"login":"TheMue","id":1633981,"avatar_url":"https://avatars.githubusercontent.com/u/1633981?v=3","gravatar_id":"","url":"https://api.github.com/users/TheMue","html_url":"https://github.com/TheMue","followers_url":"https://api.github.com/users/TheMue/followers","following_url":"https://api.github.com/users/TheMue/following{/other_user}","gists_url":"https://api.github.com/users/TheMue/gists{/gist_id}","starred_url":"https://api.github.com/users/TheMue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheMue/subscriptions","organizations_url":"https://api.github.com/users/TheMue/orgs","repos_url":"https://api.github.com/users/TheMue/repos","events_url":"https://api.github.com/users/TheMue/events{/privacy}","received_events_url":"https://api.github.com/users/TheMue/received_events","type":"User","site_admin":false},"repo":{"id":20520922,"name":"juju","full_name":"TheMue/juju","owner":{"login":"TheMue","id":1633981,"avatar_url":"https://avatars.githubusercontent.com/u/1633981?v=3","gravatar_id":"","url":"https://api.github.com/users/TheMue","html_url":"https://github.com/TheMue","followers_url":"https://api.github.com/users/TheMue/followers","following_url":"https://api.github.com/users/TheMue/following{/other_user}","gists_url":"https://api.github.com/users/TheMue/gists{/gist_id}","starred_url":"https://api.github.com/users/TheMue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheMue/subscriptions","organizations_url":"https://api.github.com/users/TheMue/orgs","repos_url":"https://api.github.com/users/TheMue/repos","events_url":"https://api.github.com/users/TheMue/events{/privacy}","received_events_url":"https://api.github.com/users/TheMue/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/TheMue/juju","description":"juju is devops distilled","fork":true,"url":"https://api.github.com/repos/TheMue/juju","forks_url":"https://api.github.com/repos/TheMue/juju/forks","keys_url":"https://api.github.com/repos/TheMue/juju/keys{/key_id}","collaborators_url":"https://api.github.com/repos/TheMue/juju/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/TheMue/juju/teams","hooks_url":"https://api.github.com/repos/TheMue/juju/hooks","issue_events_url":"https://api.github.com/repos/TheMue/juju/issues/events{/number}","events_url":"https://api.github.com/repos/TheMue/juju/events","assignees_url":"https://api.github.com/repos/TheMue/juju/assignees{/user}","branches_url":"https://api.github.com/repos/TheMue/juju/branches{/branch}","tags_url":"https://api.github.com/repos/TheMue/juju/tags","blobs_url":"https://api.github.com/repos/TheMue/juju/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/TheMue/juju/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/TheMue/juju/git/refs{/sha}","trees_url":"https://api.github.com/repos/TheMue/juju/git/trees{/sha}","statuses_url":"https://api.github.com/repos/TheMue/juju/statuses/{sha}","languages_url":"https://api.github.com/repos/TheMue/juju/languages","stargazers_url":"https://api.github.com/repos/TheMue/juju/stargazers","contributors_url":"https://api.github.com/repos/TheMue/juju/contributors","subscribers_url":"https://api.github.com/repos/TheMue/juju/subscribers","subscription_url":"https://api.github.com/repos/TheMue/juju/subscription","commits_url":"https://api.github.com/repos/TheMue/juju/commits{/sha}","git_commits_url":"https://api.github.com/repos/TheMue/juju/git/commits{/sha}","comments_url":"https://api.github.com/repos/TheMue/juju/comments{/number}","issue_comment_url":"https://api.github.com/repos/TheMue/juju/issues/comments/{number}","contents_url":"https://api.github.com/repos/TheMue/juju/contents/{+path}","compare_url":"https://api.github.com/repos/TheMue/juju/compare/{base}...{head}","merges_url":"https://api.github.com/repos/TheMue/juju/merges","archive_url":"https://api.github.com/repos/TheMue/juju/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/TheMue/juju/downloads","issues_url":"https://api.github.com/repos/TheMue/juju/issues{/number}","pulls_url":"https://api.github.com/repos/TheMue/juju/pulls{/number}","milestones_url":"https://api.github.com/repos/TheMue/juju/milestones{/number}","notifications_url":"https://api.github.com/repos/TheMue/juju/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/TheMue/juju/labels{/name}","releases_url":"https://api.github.com/repos/TheMue/juju/releases{/id}","created_at":"2014-06-05T10:25:39Z","updated_at":"2015-02-17T16:59:19Z","pushed_at":"2015-02-17T19:59:39Z","git_url":"git://github.com/TheMue/juju.git","ssh_url":"git@github.com:TheMue/juju.git","clone_url":"https://github.com/TheMue/juju.git","svn_url":"https://github.com/TheMue/juju","homepage":"juju.ubuntu.com","size":42215,"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":"juju:master","ref":"master","sha":"690fb9f25fc84e2f86f3be4cbcfd55ebad96cf0d","user":{"login":"juju","id":4604548,"avatar_url":"https://avatars.githubusercontent.com/u/4604548?v=3","gravatar_id":"","url":"https://api.github.com/users/juju","html_url":"https://github.com/juju","followers_url":"https://api.github.com/users/juju/followers","following_url":"https://api.github.com/users/juju/following{/other_user}","gists_url":"https://api.github.com/users/juju/gists{/gist_id}","starred_url":"https://api.github.com/users/juju/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juju/subscriptions","organizations_url":"https://api.github.com/users/juju/orgs","repos_url":"https://api.github.com/users/juju/repos","events_url":"https://api.github.com/users/juju/events{/privacy}","received_events_url":"https://api.github.com/users/juju/received_events","type":"Organization","site_admin":false},"repo":{"id":20445947,"name":"juju","full_name":"juju/juju","owner":{"login":"juju","id":4604548,"avatar_url":"https://avatars.githubusercontent.com/u/4604548?v=3","gravatar_id":"","url":"https://api.github.com/users/juju","html_url":"https://github.com/juju","followers_url":"https://api.github.com/users/juju/followers","following_url":"https://api.github.com/users/juju/following{/other_user}","gists_url":"https://api.github.com/users/juju/gists{/gist_id}","starred_url":"https://api.github.com/users/juju/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juju/subscriptions","organizations_url":"https://api.github.com/users/juju/orgs","repos_url":"https://api.github.com/users/juju/repos","events_url":"https://api.github.com/users/juju/events{/privacy}","received_events_url":"https://api.github.com/users/juju/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/juju/juju","description":"juju is devops distilled","fork":false,"url":"https://api.github.com/repos/juju/juju","forks_url":"https://api.github.com/repos/juju/juju/forks","keys_url":"https://api.github.com/repos/juju/juju/keys{/key_id}","collaborators_url":"https://api.github.com/repos/juju/juju/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/juju/juju/teams","hooks_url":"https://api.github.com/repos/juju/juju/hooks","issue_events_url":"https://api.github.com/repos/juju/juju/issues/events{/number}","events_url":"https://api.github.com/repos/juju/juju/events","assignees_url":"https://api.github.com/repos/juju/juju/assignees{/user}","branches_url":"https://api.github.com/repos/juju/juju/branches{/branch}","tags_url":"https://api.github.com/repos/juju/juju/tags","blobs_url":"https://api.github.com/repos/juju/juju/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/juju/juju/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/juju/juju/git/refs{/sha}","trees_url":"https://api.github.com/repos/juju/juju/git/trees{/sha}","statuses_url":"https://api.github.com/repos/juju/juju/statuses/{sha}","languages_url":"https://api.github.com/repos/juju/juju/languages","stargazers_url":"https://api.github.com/repos/juju/juju/stargazers","contributors_url":"https://api.github.com/repos/juju/juju/contributors","subscribers_url":"https://api.github.com/repos/juju/juju/subscribers","subscription_url":"https://api.github.com/repos/juju/juju/subscription","commits_url":"https://api.github.com/repos/juju/juju/commits{/sha}","git_commits_url":"https://api.github.com/repos/juju/juju/git/commits{/sha}","comments_url":"https://api.github.com/repos/juju/juju/comments{/number}","issue_comment_url":"https://api.github.com/repos/juju/juju/issues/comments/{number}","contents_url":"https://api.github.com/repos/juju/juju/contents/{+path}","compare_url":"https://api.github.com/repos/juju/juju/compare/{base}...{head}","merges_url":"https://api.github.com/repos/juju/juju/merges","archive_url":"https://api.github.com/repos/juju/juju/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/juju/juju/downloads","issues_url":"https://api.github.com/repos/juju/juju/issues{/number}","pulls_url":"https://api.github.com/repos/juju/juju/pulls{/number}","milestones_url":"https://api.github.com/repos/juju/juju/milestones{/number}","notifications_url":"https://api.github.com/repos/juju/juju/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/juju/juju/labels{/name}","releases_url":"https://api.github.com/repos/juju/juju/releases{/id}","created_at":"2014-06-03T14:28:10Z","updated_at":"2015-02-18T02:39:17Z","pushed_at":"2015-02-18T02:39:17Z","git_url":"git://github.com/juju/juju.git","ssh_url":"git@github.com:juju/juju.git","clone_url":"https://github.com/juju/juju.git","svn_url":"https://github.com/juju/juju","homepage":"juju.ubuntu.com","size":57688,"stargazers_count":243,"watchers_count":243,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":81,"mirror_url":null,"open_issues_count":65,"forks":81,"open_issues":65,"watchers":243,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/juju/juju/pulls/1617"},"html":{"href":"https://github.com/juju/juju/pull/1617"},"issue":{"href":"https://api.github.com/repos/juju/juju/issues/1617"},"comments":{"href":"https://api.github.com/repos/juju/juju/issues/1617/comments"},"review_comments":{"href":"https://api.github.com/repos/juju/juju/pulls/1617/comments"},"review_comment":{"href":"https://api.github.com/repos/juju/juju/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/juju/juju/pulls/1617/commits"},"statuses":{"href":"https://api.github.com/repos/juju/juju/statuses/1bdebafcc9f3e5fcb3bf3ce529e92ca0e0d7c509"}}}}