{"action":"created","comment":{"url":"https://api.github.com/repos/yarpc/yarpc-go/pulls/comments/55431255","id":55431255,"diff_hunk":"@@ -0,0 +1,152 @@\n+// Copyright (c) 2016 Uber Technologies, Inc.\n+//\n+// Permission is hereby granted, free of charge, to any person obtaining a copy\n+// of this software and associated documentation files (the \"Software\"), to deal\n+// in the Software without restriction, including without limitation the rights\n+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n+// copies of the Software, and to permit persons to whom the Software is\n+// furnished to do so, subject to the following conditions:\n+//\n+// The above copyright notice and this permission notice shall be included in\n+// all copies or substantial portions of the Software.\n+//\n+// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n+// THE SOFTWARE.\n+\n+package transport_test\n+\n+import (\n+\t\"bytes\"\n+\t\"fmt\"\n+\t\"io\"\n+\t\"io/ioutil\"\n+\t\"testing\"\n+\t\"time\"\n+\n+\t\"golang.org/x/net/context\"\n+\n+\t\"github.com/yarpc/yarpc-go/encoding/raw\"\n+\t\"github.com/yarpc/yarpc-go/transport\"\n+\t\"github.com/yarpc/yarpc-go/transport/http\"\n+\ttch \"github.com/yarpc/yarpc-go/transport/tchannel\"\n+\t\"github.com/yarpc/yarpc-go/transport/transporttest\"\n+\n+\t\"github.com/stretchr/testify/assert\"\n+\t\"github.com/stretchr/testify/require\"\n+\t\"github.com/uber/tchannel-go\"\n+\t\"github.com/uber/tchannel-go/testutils\"\n+)\n+\n+// all tests in this file should use these names for callers and services.\n+const (\n+\ttestCaller  = \"testService-client\"\n+\ttestService = \"testService\"\n+)\n+\n+// roundTripTransport provides a function that sets up and tears down an\n+// Inbound, and provides an Outbound which knows how to call that Inbound.\n+type roundTripTransport interface {\n+\t// Set up an Inbound serving Handler h, and call f with an Outbound that\n+\t// knows how to talk to that Inbound.\n+\tWithHandler(h transport.Handler, f func(transport.Outbound))\n+}\n+\n+// handlerFunc wraps a function into a transport.Handler\n+type handlerFunc func(context.Context, *transport.Request, transport.ResponseWriter) error\n+\n+func (f handlerFunc) Handle(ctx context.Context, r *transport.Request, w transport.ResponseWriter) error {\n+\treturn f(ctx, r, w)\n+}\n+\n+// httpTransport implements a roundTripTransport for HTTP.\n+type httpTransport struct{ t *testing.T }\n+\n+func (ht httpTransport) WithHandler(h transport.Handler, f func(transport.Outbound)) {\n+\ti := http.NewInbound(\"127.0.0.1:0\")\n+\trequire.NoError(ht.t, i.Start(h), \"failed to start\")\n+\tdefer i.Stop()\n+\n+\taddr := fmt.Sprintf(\"http://%v/\", i.Addr().String())\n+\to := http.NewOutbound(addr)\n+\tf(o)\n+}\n+\n+// tchannelTransport implements a roundTripTransport for TChannel.\n+type tchannelTransport struct{ t *testing.T }\n+\n+func (tt tchannelTransport) WithHandler(h transport.Handler, f func(transport.Outbound)) {\n+\tserverOpts := testutils.NewOpts().SetServiceName(testService)\n+\tclientOpts := testutils.NewOpts().SetServiceName(testCaller)\n+\ttestutils.WithServer(tt.t, serverOpts, func(ch *tchannel.Channel, hostPort string) {\n+\t\ti := tch.NewInbound(ch)\n+\t\trequire.NoError(tt.t, i.Start(h), \"failed to start\")\n+\t\tdefer i.Stop()\n+\t\t// ^ the server is already listening so this will just set up the\n+\t\t// handler.\n+\n+\t\tclient := testutils.NewClient(tt.t, clientOpts)\n+\t\to := tch.NewOutbound(client, tch.HostPort(hostPort))\n+\n+\t\tf(o)\n+\t})\n+}\n+\n+func TestSimpleRoundTrip(t *testing.T) {\n+\ttests := []roundTripTransport{\n+\t\thttpTransport{t},\n+\t\ttchannelTransport{t},\n+\t}\n+\n+\trequest := &transport.Request{\n+\t\tCaller:    testCaller,\n+\t\tService:   testService,\n+\t\tProcedure: \"hello\",\n+\t\tEncoding:  raw.Encoding,\n+\t\tHeaders:   transport.Headers{\"token\": \"1234\"},","path":"transport/roundtrip_test.go","position":110,"original_position":110,"commit_id":"0c4005a426f8a96063507722eb4c7cd48d4f59a7","original_commit_id":"0c4005a426f8a96063507722eb4c7cd48d4f59a7","user":{"login":"abhinav","id":41730,"avatar_url":"https://avatars.githubusercontent.com/u/41730?v=3","gravatar_id":"","url":"https://api.github.com/users/abhinav","html_url":"https://github.com/abhinav","followers_url":"https://api.github.com/users/abhinav/followers","following_url":"https://api.github.com/users/abhinav/following{/other_user}","gists_url":"https://api.github.com/users/abhinav/gists{/gist_id}","starred_url":"https://api.github.com/users/abhinav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abhinav/subscriptions","organizations_url":"https://api.github.com/users/abhinav/orgs","repos_url":"https://api.github.com/users/abhinav/repos","events_url":"https://api.github.com/users/abhinav/events{/privacy}","received_events_url":"https://api.github.com/users/abhinav/received_events","type":"User","site_admin":false},"body":"We'll probable expose another copy of the Headers object at the top-level. Created #68.\r\n","created_at":"2016-03-08T21:31:29Z","updated_at":"2016-03-08T21:31:29Z","html_url":"https://github.com/yarpc/yarpc-go/pull/63#discussion_r55431255","pull_request_url":"https://api.github.com/repos/yarpc/yarpc-go/pulls/63","_links":{"self":{"href":"https://api.github.com/repos/yarpc/yarpc-go/pulls/comments/55431255"},"html":{"href":"https://github.com/yarpc/yarpc-go/pull/63#discussion_r55431255"},"pull_request":{"href":"https://api.github.com/repos/yarpc/yarpc-go/pulls/63"}}},"pull_request":{"url":"https://api.github.com/repos/yarpc/yarpc-go/pulls/63","id":62009527,"html_url":"https://github.com/yarpc/yarpc-go/pull/63","diff_url":"https://github.com/yarpc/yarpc-go/pull/63.diff","patch_url":"https://github.com/yarpc/yarpc-go/pull/63.patch","issue_url":"https://api.github.com/repos/yarpc/yarpc-go/issues/63","number":63,"state":"open","locked":false,"title":"Generalize HTTP round trip test to test TChannel as well","user":{"login":"abhinav","id":41730,"avatar_url":"https://avatars.githubusercontent.com/u/41730?v=3","gravatar_id":"","url":"https://api.github.com/users/abhinav","html_url":"https://github.com/abhinav","followers_url":"https://api.github.com/users/abhinav/followers","following_url":"https://api.github.com/users/abhinav/following{/other_user}","gists_url":"https://api.github.com/users/abhinav/gists{/gist_id}","starred_url":"https://api.github.com/users/abhinav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abhinav/subscriptions","organizations_url":"https://api.github.com/users/abhinav/orgs","repos_url":"https://api.github.com/users/abhinav/repos","events_url":"https://api.github.com/users/abhinav/events{/privacy}","received_events_url":"https://api.github.com/users/abhinav/received_events","type":"User","site_admin":false},"body":"Depends on #62.\n\n<!-- Reviewable:start -->\n[<img src=\"https://reviewable.io/review_button.svg\" height=\"40\" alt=\"Review on Reviewable\"/>](https://reviewable.io/reviews/yarpc/yarpc-go/63)\n<!-- Reviewable:end -->\n","created_at":"2016-03-08T01:14:49Z","updated_at":"2016-03-08T21:31:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c02f4ffa86f0d07a6b4cf41d5e1728cbadd1e438","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/yarpc/yarpc-go/pulls/63/commits","review_comments_url":"https://api.github.com/repos/yarpc/yarpc-go/pulls/63/comments","review_comment_url":"https://api.github.com/repos/yarpc/yarpc-go/pulls/comments{/number}","comments_url":"https://api.github.com/repos/yarpc/yarpc-go/issues/63/comments","statuses_url":"https://api.github.com/repos/yarpc/yarpc-go/statuses/0c4005a426f8a96063507722eb4c7cd48d4f59a7","head":{"label":"yarpc:roundtrip","ref":"roundtrip","sha":"0c4005a426f8a96063507722eb4c7cd48d4f59a7","user":{"login":"yarpc","id":16569504,"avatar_url":"https://avatars.githubusercontent.com/u/16569504?v=3","gravatar_id":"","url":"https://api.github.com/users/yarpc","html_url":"https://github.com/yarpc","followers_url":"https://api.github.com/users/yarpc/followers","following_url":"https://api.github.com/users/yarpc/following{/other_user}","gists_url":"https://api.github.com/users/yarpc/gists{/gist_id}","starred_url":"https://api.github.com/users/yarpc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yarpc/subscriptions","organizations_url":"https://api.github.com/users/yarpc/orgs","repos_url":"https://api.github.com/users/yarpc/repos","events_url":"https://api.github.com/users/yarpc/events{/privacy}","received_events_url":"https://api.github.com/users/yarpc/received_events","type":"Organization","site_admin":false},"repo":{"id":50390111,"name":"yarpc-go","full_name":"yarpc/yarpc-go","owner":{"login":"yarpc","id":16569504,"avatar_url":"https://avatars.githubusercontent.com/u/16569504?v=3","gravatar_id":"","url":"https://api.github.com/users/yarpc","html_url":"https://github.com/yarpc","followers_url":"https://api.github.com/users/yarpc/followers","following_url":"https://api.github.com/users/yarpc/following{/other_user}","gists_url":"https://api.github.com/users/yarpc/gists{/gist_id}","starred_url":"https://api.github.com/users/yarpc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yarpc/subscriptions","organizations_url":"https://api.github.com/users/yarpc/orgs","repos_url":"https://api.github.com/users/yarpc/repos","events_url":"https://api.github.com/users/yarpc/events{/privacy}","received_events_url":"https://api.github.com/users/yarpc/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/yarpc/yarpc-go","description":"YARPC for Golang","fork":false,"url":"https://api.github.com/repos/yarpc/yarpc-go","forks_url":"https://api.github.com/repos/yarpc/yarpc-go/forks","keys_url":"https://api.github.com/repos/yarpc/yarpc-go/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yarpc/yarpc-go/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yarpc/yarpc-go/teams","hooks_url":"https://api.github.com/repos/yarpc/yarpc-go/hooks","issue_events_url":"https://api.github.com/repos/yarpc/yarpc-go/issues/events{/number}","events_url":"https://api.github.com/repos/yarpc/yarpc-go/events","assignees_url":"https://api.github.com/repos/yarpc/yarpc-go/assignees{/user}","branches_url":"https://api.github.com/repos/yarpc/yarpc-go/branches{/branch}","tags_url":"https://api.github.com/repos/yarpc/yarpc-go/tags","blobs_url":"https://api.github.com/repos/yarpc/yarpc-go/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yarpc/yarpc-go/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yarpc/yarpc-go/git/refs{/sha}","trees_url":"https://api.github.com/repos/yarpc/yarpc-go/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yarpc/yarpc-go/statuses/{sha}","languages_url":"https://api.github.com/repos/yarpc/yarpc-go/languages","stargazers_url":"https://api.github.com/repos/yarpc/yarpc-go/stargazers","contributors_url":"https://api.github.com/repos/yarpc/yarpc-go/contributors","subscribers_url":"https://api.github.com/repos/yarpc/yarpc-go/subscribers","subscription_url":"https://api.github.com/repos/yarpc/yarpc-go/subscription","commits_url":"https://api.github.com/repos/yarpc/yarpc-go/commits{/sha}","git_commits_url":"https://api.github.com/repos/yarpc/yarpc-go/git/commits{/sha}","comments_url":"https://api.github.com/repos/yarpc/yarpc-go/comments{/number}","issue_comment_url":"https://api.github.com/repos/yarpc/yarpc-go/issues/comments{/number}","contents_url":"https://api.github.com/repos/yarpc/yarpc-go/contents/{+path}","compare_url":"https://api.github.com/repos/yarpc/yarpc-go/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yarpc/yarpc-go/merges","archive_url":"https://api.github.com/repos/yarpc/yarpc-go/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yarpc/yarpc-go/downloads","issues_url":"https://api.github.com/repos/yarpc/yarpc-go/issues{/number}","pulls_url":"https://api.github.com/repos/yarpc/yarpc-go/pulls{/number}","milestones_url":"https://api.github.com/repos/yarpc/yarpc-go/milestones{/number}","notifications_url":"https://api.github.com/repos/yarpc/yarpc-go/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yarpc/yarpc-go/labels{/name}","releases_url":"https://api.github.com/repos/yarpc/yarpc-go/releases{/id}","deployments_url":"https://api.github.com/repos/yarpc/yarpc-go/deployments","created_at":"2016-01-26T00:04:14Z","updated_at":"2016-02-13T21:03:37Z","pushed_at":"2016-03-08T19:48:20Z","git_url":"git://github.com/yarpc/yarpc-go.git","ssh_url":"git@github.com:yarpc/yarpc-go.git","clone_url":"https://github.com/yarpc/yarpc-go.git","svn_url":"https://github.com/yarpc/yarpc-go","homepage":"","size":3412,"stargazers_count":1,"watchers_count":1,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":12,"forks":0,"open_issues":12,"watchers":1,"default_branch":"master"}},"base":{"label":"yarpc:tests","ref":"tests","sha":"ee962e4b99dd7b5daa06950a4e853cca4988898e","user":{"login":"yarpc","id":16569504,"avatar_url":"https://avatars.githubusercontent.com/u/16569504?v=3","gravatar_id":"","url":"https://api.github.com/users/yarpc","html_url":"https://github.com/yarpc","followers_url":"https://api.github.com/users/yarpc/followers","following_url":"https://api.github.com/users/yarpc/following{/other_user}","gists_url":"https://api.github.com/users/yarpc/gists{/gist_id}","starred_url":"https://api.github.com/users/yarpc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yarpc/subscriptions","organizations_url":"https://api.github.com/users/yarpc/orgs","repos_url":"https://api.github.com/users/yarpc/repos","events_url":"https://api.github.com/users/yarpc/events{/privacy}","received_events_url":"https://api.github.com/users/yarpc/received_events","type":"Organization","site_admin":false},"repo":{"id":50390111,"name":"yarpc-go","full_name":"yarpc/yarpc-go","owner":{"login":"yarpc","id":16569504,"avatar_url":"https://avatars.githubusercontent.com/u/16569504?v=3","gravatar_id":"","url":"https://api.github.com/users/yarpc","html_url":"https://github.com/yarpc","followers_url":"https://api.github.com/users/yarpc/followers","following_url":"https://api.github.com/users/yarpc/following{/other_user}","gists_url":"https://api.github.com/users/yarpc/gists{/gist_id}","starred_url":"https://api.github.com/users/yarpc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yarpc/subscriptions","organizations_url":"https://api.github.com/users/yarpc/orgs","repos_url":"https://api.github.com/users/yarpc/repos","events_url":"https://api.github.com/users/yarpc/events{/privacy}","received_events_url":"https://api.github.com/users/yarpc/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/yarpc/yarpc-go","description":"YARPC for Golang","fork":false,"url":"https://api.github.com/repos/yarpc/yarpc-go","forks_url":"https://api.github.com/repos/yarpc/yarpc-go/forks","keys_url":"https://api.github.com/repos/yarpc/yarpc-go/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yarpc/yarpc-go/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yarpc/yarpc-go/teams","hooks_url":"https://api.github.com/repos/yarpc/yarpc-go/hooks","issue_events_url":"https://api.github.com/repos/yarpc/yarpc-go/issues/events{/number}","events_url":"https://api.github.com/repos/yarpc/yarpc-go/events","assignees_url":"https://api.github.com/repos/yarpc/yarpc-go/assignees{/user}","branches_url":"https://api.github.com/repos/yarpc/yarpc-go/branches{/branch}","tags_url":"https://api.github.com/repos/yarpc/yarpc-go/tags","blobs_url":"https://api.github.com/repos/yarpc/yarpc-go/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yarpc/yarpc-go/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yarpc/yarpc-go/git/refs{/sha}","trees_url":"https://api.github.com/repos/yarpc/yarpc-go/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yarpc/yarpc-go/statuses/{sha}","languages_url":"https://api.github.com/repos/yarpc/yarpc-go/languages","stargazers_url":"https://api.github.com/repos/yarpc/yarpc-go/stargazers","contributors_url":"https://api.github.com/repos/yarpc/yarpc-go/contributors","subscribers_url":"https://api.github.com/repos/yarpc/yarpc-go/subscribers","subscription_url":"https://api.github.com/repos/yarpc/yarpc-go/subscription","commits_url":"https://api.github.com/repos/yarpc/yarpc-go/commits{/sha}","git_commits_url":"https://api.github.com/repos/yarpc/yarpc-go/git/commits{/sha}","comments_url":"https://api.github.com/repos/yarpc/yarpc-go/comments{/number}","issue_comment_url":"https://api.github.com/repos/yarpc/yarpc-go/issues/comments{/number}","contents_url":"https://api.github.com/repos/yarpc/yarpc-go/contents/{+path}","compare_url":"https://api.github.com/repos/yarpc/yarpc-go/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yarpc/yarpc-go/merges","archive_url":"https://api.github.com/repos/yarpc/yarpc-go/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yarpc/yarpc-go/downloads","issues_url":"https://api.github.com/repos/yarpc/yarpc-go/issues{/number}","pulls_url":"https://api.github.com/repos/yarpc/yarpc-go/pulls{/number}","milestones_url":"https://api.github.com/repos/yarpc/yarpc-go/milestones{/number}","notifications_url":"https://api.github.com/repos/yarpc/yarpc-go/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yarpc/yarpc-go/labels{/name}","releases_url":"https://api.github.com/repos/yarpc/yarpc-go/releases{/id}","deployments_url":"https://api.github.com/repos/yarpc/yarpc-go/deployments","created_at":"2016-01-26T00:04:14Z","updated_at":"2016-02-13T21:03:37Z","pushed_at":"2016-03-08T19:48:20Z","git_url":"git://github.com/yarpc/yarpc-go.git","ssh_url":"git@github.com:yarpc/yarpc-go.git","clone_url":"https://github.com/yarpc/yarpc-go.git","svn_url":"https://github.com/yarpc/yarpc-go","homepage":"","size":3412,"stargazers_count":1,"watchers_count":1,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":12,"forks":0,"open_issues":12,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/yarpc/yarpc-go/pulls/63"},"html":{"href":"https://github.com/yarpc/yarpc-go/pull/63"},"issue":{"href":"https://api.github.com/repos/yarpc/yarpc-go/issues/63"},"comments":{"href":"https://api.github.com/repos/yarpc/yarpc-go/issues/63/comments"},"review_comments":{"href":"https://api.github.com/repos/yarpc/yarpc-go/pulls/63/comments"},"review_comment":{"href":"https://api.github.com/repos/yarpc/yarpc-go/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/yarpc/yarpc-go/pulls/63/commits"},"statuses":{"href":"https://api.github.com/repos/yarpc/yarpc-go/statuses/0c4005a426f8a96063507722eb4c7cd48d4f59a7"}}}}