MCPcopy Index your code
hub / github.com/google/go-github / TestRepositoriesService_GetKey

Function TestRepositoriesService_GetKey

github/repos_keys_test.go:62–95  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

60}
61
62func TestRepositoriesService_GetKey(t *testing.T) {
63 t.Parallel()
64 client, mux, _ := setup(t)
65
66 mux.HandleFunc("/repos/o/r/keys/1", func(w http.ResponseWriter, r *http.Request) {
67 testMethod(t, r, "GET")
68 fmt.Fprint(w, `{"id":1}`)
69 })
70
71 ctx := t.Context()
72 key, _, err := client.Repositories.GetKey(ctx, "o", "r", 1)
73 if err != nil {
74 t.Errorf("Repositories.GetKey returned error: %v", err)
75 }
76
77 want := &Key{ID: Ptr(int64(1))}
78 if !cmp.Equal(key, want) {
79 t.Errorf("Repositories.GetKey returned %+v, want %+v", key, want)
80 }
81
82 const methodName = "GetKey"
83 testBadOptions(t, methodName, func() (err error) {
84 _, _, err = client.Repositories.GetKey(ctx, "\n", "\n", -1)
85 return err
86 })
87
88 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
89 got, resp, err := client.Repositories.GetKey(ctx, "o", "r", 1)
90 if got != nil {
91 t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
92 }
93 return resp, err
94 })
95}
96
97func TestRepositoriesService_GetKey_invalidOwner(t *testing.T) {
98 t.Parallel()

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…