Skip to content

Commit

Permalink
tests: make use of testMethod consistent (google#832)
Browse files Browse the repository at this point in the history
Use testMethod to test the request method instead of manually comparing
it and testing. This change is to make things consistent through out the
code base.

Fixes google#829.
  • Loading branch information
sahildua2305 authored and gmlewis committed Jan 16, 2018
1 parent a374780 commit ac6ae88
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
12 changes: 3 additions & 9 deletions github/git_trees_test.go
Expand Up @@ -19,9 +19,7 @@ func TestGitService_GetTree(t *testing.T) {
defer teardown()

mux.HandleFunc("/repos/o/r/git/trees/s", func(w http.ResponseWriter, r *http.Request) {
if m := "GET"; m != r.Method {
t.Errorf("Request method = %v, want %v", r.Method, m)
}
testMethod(t, r, "GET")
fmt.Fprint(w, `{
"sha": "s",
"tree": [ { "type": "blob" } ]
Expand Down Expand Up @@ -71,9 +69,7 @@ func TestGitService_CreateTree(t *testing.T) {
v := new(createTree)
json.NewDecoder(r.Body).Decode(v)

if m := "POST"; m != r.Method {
t.Errorf("Request method = %v, want %v", r.Method, m)
}
testMethod(t, r, "POST")

want := &createTree{
BaseTree: "b",
Expand Down Expand Up @@ -136,9 +132,7 @@ func TestGitService_CreateTree_Content(t *testing.T) {
v := new(createTree)
json.NewDecoder(r.Body).Decode(v)

if m := "POST"; m != r.Method {
t.Errorf("Request method = %v, want %v", r.Method, m)
}
testMethod(t, r, "POST")

want := &createTree{
BaseTree: "b",
Expand Down
8 changes: 2 additions & 6 deletions github/github_test.go
Expand Up @@ -413,9 +413,7 @@ func TestDo(t *testing.T) {
}

mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
if m := "GET"; m != r.Method {
t.Errorf("Request method = %v, want %v", r.Method, m)
}
testMethod(t, r, "GET")
fmt.Fprint(w, `{"A":"a"}`)
})

Expand Down Expand Up @@ -853,9 +851,7 @@ func TestRateLimits(t *testing.T) {
defer teardown()

mux.HandleFunc("/rate_limit", func(w http.ResponseWriter, r *http.Request) {
if m := "GET"; m != r.Method {
t.Errorf("Request method = %v, want %v", r.Method, m)
}
testMethod(t, r, "GET")
fmt.Fprint(w, `{"resources":{
"core": {"limit":2,"remaining":1,"reset":1372700873},
"search": {"limit":3,"remaining":2,"reset":1372700874}
Expand Down

0 comments on commit ac6ae88

Please sign in to comment.