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

Function TestUsersService_GetKey

github/users_keys_test.go:83–116  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

81}
82
83func TestUsersService_GetKey(t *testing.T) {
84 t.Parallel()
85 client, mux, _ := setup(t)
86
87 mux.HandleFunc("/user/keys/1", func(w http.ResponseWriter, r *http.Request) {
88 testMethod(t, r, "GET")
89 fmt.Fprint(w, `{"id":1}`)
90 })
91
92 ctx := t.Context()
93 key, _, err := client.Users.GetKey(ctx, 1)
94 if err != nil {
95 t.Errorf("Users.GetKey returned error: %v", err)
96 }
97
98 want := &Key{ID: Ptr(int64(1))}
99 if !cmp.Equal(key, want) {
100 t.Errorf("Users.GetKey returned %+v, want %+v", key, want)
101 }
102
103 const methodName = "GetKey"
104 testBadOptions(t, methodName, func() (err error) {
105 _, _, err = client.Users.GetKey(ctx, -1)
106 return err
107 })
108
109 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
110 got, resp, err := client.Users.GetKey(ctx, 1)
111 if got != nil {
112 t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
113 }
114 return resp, err
115 })
116}
117
118func TestUsersService_CreateKey(t *testing.T) {
119 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…