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

Function TestUsersService_CreateKey

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

Source from the content-addressed store, hash-verified

116}
117
118func TestUsersService_CreateKey(t *testing.T) {
119 t.Parallel()
120 client, mux, _ := setup(t)
121
122 input := &Key{Key: Ptr("k"), Title: Ptr("t")}
123
124 mux.HandleFunc("/user/keys", func(w http.ResponseWriter, r *http.Request) {
125 testMethod(t, r, "POST")
126 testJSONBody(t, r, input)
127 fmt.Fprint(w, `{"id":1}`)
128 })
129
130 ctx := t.Context()
131 key, _, err := client.Users.CreateKey(ctx, input)
132 if err != nil {
133 t.Errorf("Users.CreateKey returned error: %v", err)
134 }
135
136 want := &Key{ID: Ptr(int64(1))}
137 if !cmp.Equal(key, want) {
138 t.Errorf("Users.CreateKey returned %+v, want %+v", key, want)
139 }
140
141 const methodName = "CreateKey"
142 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
143 got, resp, err := client.Users.CreateKey(ctx, input)
144 if got != nil {
145 t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
146 }
147 return resp, err
148 })
149}
150
151func TestUsersService_DeleteKey(t *testing.T) {
152 t.Parallel()

Callers

nothing calls this directly

Calls 7

testMethodFunction · 0.85
testJSONBodyFunction · 0.85
EqualMethod · 0.80
setupFunction · 0.70
PtrFunction · 0.70
CreateKeyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…