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

Function TestUsersService_AddEmails

github/users_emails_test.go:52–86  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

50}
51
52func TestUsersService_AddEmails(t *testing.T) {
53 t.Parallel()
54 client, mux, _ := setup(t)
55
56 input := []string{"new@example.com"}
57
58 mux.HandleFunc("/user/emails", func(w http.ResponseWriter, r *http.Request) {
59 testMethod(t, r, "POST")
60 testJSONBody(t, r, input)
61 fmt.Fprint(w, `[{"email":"old@example.com"}, {"email":"new@example.com"}]`)
62 })
63
64 ctx := t.Context()
65 emails, _, err := client.Users.AddEmails(ctx, input)
66 if err != nil {
67 t.Errorf("Users.AddEmails returned error: %v", err)
68 }
69
70 want := []*UserEmail{
71 {Email: Ptr("old@example.com")},
72 {Email: Ptr("new@example.com")},
73 }
74 if !cmp.Equal(emails, want) {
75 t.Errorf("Users.AddEmails returned %+v, want %+v", emails, want)
76 }
77
78 const methodName = "AddEmails"
79 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
80 got, resp, err := client.Users.AddEmails(ctx, input)
81 if got != nil {
82 t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
83 }
84 return resp, err
85 })
86}
87
88func TestUsersService_DeleteEmails(t *testing.T) {
89 t.Parallel()

Callers

nothing calls this directly

Calls 7

testMethodFunction · 0.85
testJSONBodyFunction · 0.85
AddEmailsMethod · 0.80
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…