GitHub PullRequestReviewCommentEvent at 2014-06-05 15:52:39
Repository: ent
Actor: peterbourgon
Payload: {"comment":{"url":"https://api.github.com/repos/soundcloud/ent/pulls/comments/13447571","id":13447571,"diff_hunk":"@@ -277,57 +270,58 @@ type responseFileWrapper struct {\n \tSHA1   string  `json:\"sha1\"`\n }\n \n-func report(\n-\trwd *exp.ResponseWriterDelegator,\n-\tr *http.Request,\n-\trd *ReaderDelegator,\n-\tb *Bucket,\n-\tbegan time.Time,\n-\top string,\n-) {\n-\td := time.Since(began)\n-\tlabels := map[string]string{\n-\t\t\"method\":    strings.ToLower(r.Method),\n-\t\t\"operation\": op,\n-\t\t\"status\":    rwd.Status(),\n-\t}\n+func metrics(op string, next http.Handler) http.Handler {\n+\treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n+\t\tvar (\n+\t\t\tstart = time.Now()\n+\t\t\trd    = &readerDelegator{ReadCloser: r.Body}\n+\t\t\trc    = &responseRecorder{ResponseWriter: w}\n+\t\t)\n \n-\tif b != nil {\n-\t\tlabels[\"bucket\"] = b.Name\n-\t}\n+\t\tr.Body = rd\n \n-\tif rd != nil {\n-\t\trequestBytes.IncrementBy(labels, float64(rd.BytesRead))\n-\t}\n+\t\tnext.ServeHTTP(rc, r)\n+\n+\t\td := time.Since(start)\n+\t\tlabels := map[string]string{\n+\t\t\t\"bucket\":    r.URL.Query().Get(\":bucket\"),","path":"ent.go","position":271,"original_position":271,"commit_id":"011e380d8dda03c963e11438391b8793a800b01b","original_commit_id":"011e380d8dda03c963e11438391b8793a800b01b","user":{"login":"peterbourgon","id":114509,"avatar_url":"https://avatars.githubusercontent.com/u/114509?","gravatar_id":"30cbfad07178498c9c264c30413c93b1","url":"https://api.github.com/users/peterbourgon","html_url":"https://github.com/peterbourgon","followers_url":"https://api.github.com/users/peterbourgon/followers","following_url":"https://api.github.com/users/peterbourgon/following{/other_user}","gists_url":"https://api.github.com/users/peterbourgon/gists{/gist_id}","starred_url":"https://api.github.com/users/peterbourgon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peterbourgon/subscriptions","organizations_url":"https://api.github.com/users/peterbourgon/orgs","repos_url":"https://api.github.com/users/peterbourgon/repos","events_url":"https://api.github.com/users/peterbourgon/events{/privacy}","received_events_url":"https://api.github.com/users/peterbourgon/received_events","type":"User","site_admin":false},"body":"I think it would be a good idea, yes. I guess the easiest thing would be, for each route/handler pair you want to test, spin up a httptest.Server with a pat router binding to your handler with mock data backends or whatever, and then pushing a real request through, and making sure your mocks got updated as you expect. I do something vaguely similar [here](https://github.com/soundcloud/media-service/blob/sanitize/xurlgen/handlers_test.go#L177).","created_at":"2014-06-05T15:52:39Z","updated_at":"2014-06-05T15:52:39Z","html_url":"https://github.com/soundcloud/ent/pull/6#discussion_r13447571","pull_request_url":"https://api.github.com/repos/soundcloud/ent/pulls/6","_links":{"self":{"href":"https://api.github.com/repos/soundcloud/ent/pulls/comments/13447571"},"html":{"href":"https://github.com/soundcloud/ent/pull/6#discussion_r13447571"},"pull_request":{"href":"https://api.github.com/repos/soundcloud/ent/pulls/6"}}}}