MCPcopy Create free account
hub / github.com/google/go-github / TestAppsService_CreateInstallationToken

Function TestAppsService_CreateInstallationToken

github/apps_test.go:403–436  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

401}
402
403func TestAppsService_CreateInstallationToken(t *testing.T) {
404 t.Parallel()
405 client, mux, _ := setup(t)
406
407 mux.HandleFunc("/app/installations/1/access_tokens", func(w http.ResponseWriter, r *http.Request) {
408 testMethod(t, r, "POST")
409 fmt.Fprint(w, `{"token":"t"}`)
410 })
411
412 ctx := t.Context()
413 token, _, err := client.Apps.CreateInstallationToken(ctx, 1, nil)
414 if err != nil {
415 t.Errorf("Apps.CreateInstallationToken returned error: %v", err)
416 }
417
418 want := &InstallationToken{Token: Ptr("t")}
419 if !cmp.Equal(token, want) {
420 t.Errorf("Apps.CreateInstallationToken returned %+v, want %+v", token, want)
421 }
422
423 const methodName = "CreateInstallationToken"
424 testBadOptions(t, methodName, func() (err error) {
425 _, _, err = client.Apps.CreateInstallationToken(ctx, -1, nil)
426 return err
427 })
428
429 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
430 got, resp, err := client.Apps.CreateInstallationToken(ctx, 1, nil)
431 if got != nil {
432 t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
433 }
434 return resp, err
435 })
436}
437
438func TestAppsService_CreateInstallationTokenWithOptions(t *testing.T) {
439 t.Parallel()

Callers

nothing calls this directly

Calls 7

testMethodFunction · 0.85
testBadOptionsFunction · 0.85
EqualMethod · 0.80
setupFunction · 0.70
PtrFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…