(t *testing.T)
| 233 | } |
| 234 | |
| 235 | func TestRepositoriesService_GetCommitSHA1(t *testing.T) { |
| 236 | t.Parallel() |
| 237 | client, mux, _ := setup(t) |
| 238 | |
| 239 | const sha1 = "01234abcde" |
| 240 | |
| 241 | mux.HandleFunc("/repos/o/r/commits/master", func(w http.ResponseWriter, r *http.Request) { |
| 242 | testMethod(t, r, "GET") |
| 243 | testHeader(t, r, "Accept", mediaTypeV3SHA) |
| 244 | |
| 245 | fmt.Fprint(w, sha1) |
| 246 | }) |
| 247 | |
| 248 | ctx := t.Context() |
| 249 | got, _, err := client.Repositories.GetCommitSHA1(ctx, "o", "r", "master", "") |
| 250 | if err != nil { |
| 251 | t.Errorf("Repositories.GetCommitSHA1 returned error: %v", err) |
| 252 | } |
| 253 | |
| 254 | want := sha1 |
| 255 | if got != want { |
| 256 | t.Errorf("Repositories.GetCommitSHA1 = %v, want %v", got, want) |
| 257 | } |
| 258 | |
| 259 | mux.HandleFunc("/repos/o/r/commits/tag", func(w http.ResponseWriter, r *http.Request) { |
| 260 | testMethod(t, r, "GET") |
| 261 | testHeader(t, r, "Accept", mediaTypeV3SHA) |
| 262 | testHeader(t, r, "If-None-Match", `"`+sha1+`"`) |
| 263 | |
| 264 | w.WriteHeader(http.StatusNotModified) |
| 265 | }) |
| 266 | |
| 267 | got, _, err = client.Repositories.GetCommitSHA1(ctx, "o", "r", "tag", sha1) |
| 268 | if err == nil { |
| 269 | t.Error("Expected HTTP 304 response") |
| 270 | } |
| 271 | |
| 272 | want = "" |
| 273 | if got != want { |
| 274 | t.Errorf("Repositories.GetCommitSHA1 = %v, want %v", got, want) |
| 275 | } |
| 276 | |
| 277 | const methodName = "GetCommitSHA1" |
| 278 | testBadOptions(t, methodName, func() (err error) { |
| 279 | _, _, err = client.Repositories.GetCommitSHA1(ctx, "\n", "\n", "\n", "\n") |
| 280 | return err |
| 281 | }) |
| 282 | |
| 283 | testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { |
| 284 | got, resp, err := client.Repositories.GetCommitSHA1(ctx, "o", "r", "master", "") |
| 285 | if got != "" { |
| 286 | t.Errorf("testNewRequestAndDoFailure %v = %#v, want ''", methodName, got) |
| 287 | } |
| 288 | return resp, err |
| 289 | }) |
| 290 | } |
| 291 | |
| 292 | func TestRepositoriesService_NonAlphabetCharacter_GetCommitSHA1(t *testing.T) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…