MCPcopy Create free account
hub / github.com/GetStream/stream-go2 / TestAddReaction

Function TestAddReaction

reactions_test.go:29–83  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

27}
28
29func TestAddReaction(t *testing.T) {
30 ctx := context.Background()
31 client, requester := newClient(t)
32
33 testCases := []struct {
34 input stream.AddReactionRequestObject
35 expectedURL string
36 expectedBody string
37 }{
38 {
39 input: stream.AddReactionRequestObject{
40 Kind: "like",
41 ActivityID: "some-act-id",
42 UserID: "user-id",
43 Data: map[string]any{
44 "field": "value",
45 },
46 },
47 expectedURL: "https://api.stream-io-api.com/api/v1.0/reaction/?api_key=key",
48 expectedBody: `{"kind":"like","activity_id":"some-act-id","user_id":"user-id","data":{"field":"value"}}`,
49 },
50 {
51 input: stream.AddReactionRequestObject{
52 Kind: "like",
53 ActivityID: "some-act-id",
54 UserID: "user-id",
55 TargetFeeds: []string{"user:bob"},
56 },
57 expectedURL: "https://api.stream-io-api.com/api/v1.0/reaction/?api_key=key",
58 expectedBody: `{"kind":"like","activity_id":"some-act-id","user_id":"user-id","target_feeds":["user:bob"]}`,
59 },
60 {
61 input: stream.AddReactionRequestObject{
62 Kind: "like",
63 ActivityID: "some-act-id",
64 UserID: "user-id",
65 Data: map[string]any{"some_extra": "on reaction"},
66 TargetFeeds: []string{"user:bob"},
67 TargetFeedsExtraData: map[string]any{"some_extra": "on activity"},
68 },
69 expectedURL: "https://api.stream-io-api.com/api/v1.0/reaction/?api_key=key",
70 expectedBody: `{
71 "kind":"like","activity_id":"some-act-id","user_id":"user-id",
72 "data":{"some_extra":"on reaction"},
73 "target_feeds":["user:bob"],
74 "target_feeds_extra_data":{"some_extra":"on activity"}
75 }`,
76 },
77 }
78 for _, tc := range testCases {
79 _, err := client.Reactions().Add(ctx, tc.input)
80 require.NoError(t, err)
81 testRequest(t, requester.req, http.MethodPost, tc.expectedURL, tc.expectedBody)
82 }
83}
84
85func TestAddChildReaction(t *testing.T) {
86 ctx := context.Background()

Callers

nothing calls this directly

Calls 4

newClientFunction · 0.85
testRequestFunction · 0.85
ReactionsMethod · 0.80
AddMethod · 0.45

Tested by

no test coverage detected