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

Function TestReactionsService_CreateCommentReaction

github/reactions_test.go:107–142  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

105}
106
107func TestReactionsService_CreateCommentReaction(t *testing.T) {
108 t.Parallel()
109 client, mux, _ := setup(t)
110
111 mux.HandleFunc("/repos/o/r/comments/1/reactions", func(w http.ResponseWriter, r *http.Request) {
112 testMethod(t, r, "POST")
113 testHeader(t, r, "Accept", mediaTypeReactionsPreview)
114
115 w.WriteHeader(http.StatusCreated)
116 assertWrite(t, w, []byte(`{"id":1,"user":{"login":"l","id":2},"content":"+1"}`))
117 })
118
119 ctx := t.Context()
120 got, _, err := client.Reactions.CreateCommentReaction(ctx, "o", "r", 1, "+1")
121 if err != nil {
122 t.Errorf("CreateCommentReaction returned error: %v", err)
123 }
124 want := &Reaction{ID: Ptr(int64(1)), User: &User{Login: Ptr("l"), ID: Ptr(int64(2))}, Content: Ptr("+1")}
125 if !cmp.Equal(got, want) {
126 t.Errorf("CreateCommentReaction = %+v, want %+v", got, want)
127 }
128
129 const methodName = "CreateCommentReaction"
130 testBadOptions(t, methodName, func() (err error) {
131 _, _, err = client.Reactions.CreateCommentReaction(ctx, "\n", "\n", -1, "\n")
132 return err
133 })
134
135 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
136 got, resp, err := client.Reactions.CreateCommentReaction(ctx, "o", "r", 1, "+1")
137 if got != nil {
138 t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
139 }
140 return resp, err
141 })
142}
143
144func TestReactionsService_ListIssueReactions(t *testing.T) {
145 t.Parallel()

Callers

nothing calls this directly

Calls 9

testMethodFunction · 0.85
testHeaderFunction · 0.85
assertWriteFunction · 0.85
testBadOptionsFunction · 0.85
CreateCommentReactionMethod · 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…