(t *testing.T)
| 86 | } |
| 87 | |
| 88 | func Test_httpRequest(t *testing.T) { |
| 89 | var tr roundTripper = func(req *http.Request) (*http.Response, error) { |
| 90 | return &http.Response{Request: req}, nil |
| 91 | } |
| 92 | httpClient := http.Client{Transport: tr} |
| 93 | |
| 94 | type args struct { |
| 95 | client *http.Client |
| 96 | host string |
| 97 | method string |
| 98 | p string |
| 99 | params interface{} |
| 100 | headers []string |
| 101 | } |
| 102 | type expects struct { |
| 103 | method string |
| 104 | u string |
| 105 | body string |
| 106 | headers string |
| 107 | } |
| 108 | tests := []struct { |
| 109 | name string |
| 110 | args args |
| 111 | want expects |
| 112 | wantErr bool |
| 113 | }{ |
| 114 | { |
| 115 | name: "simple GET", |
| 116 | args: args{ |
| 117 | client: &httpClient, |
| 118 | host: "github.com", |
| 119 | method: "GET", |
| 120 | p: "repos/octocat/spoon-knife", |
| 121 | params: nil, |
| 122 | headers: []string{}, |
| 123 | }, |
| 124 | wantErr: false, |
| 125 | want: expects{ |
| 126 | method: "GET", |
| 127 | u: "https://api.github.com/repos/octocat/spoon-knife", |
| 128 | body: "", |
| 129 | headers: "Accept: */*\r\n", |
| 130 | }, |
| 131 | }, |
| 132 | { |
| 133 | name: "GET with accept header", |
| 134 | args: args{ |
| 135 | client: &httpClient, |
| 136 | host: "github.com", |
| 137 | method: "GET", |
| 138 | p: "repos/octocat/spoon-knife", |
| 139 | params: nil, |
| 140 | headers: []string{"Accept: testing"}, |
| 141 | }, |
| 142 | wantErr: false, |
| 143 | want: expects{ |
| 144 | method: "GET", |
| 145 | u: "https://api.github.com/repos/octocat/spoon-knife", |
nothing calls this directly
no test coverage detected