MCPcopy Create free account
hub / github.com/GetStream/stream-cli / testCmd

Function testCmd

pkg/cmd/chat/push/push.go:162–216  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

160}
161
162func testCmd() *cobra.Command {
163 cmd := &cobra.Command{
164 Use: "test-push --message-id [string]" +
165 " --apn-template [string]" +
166 " --firebase-template [string]" +
167 " --firebase-data-template [string]" +
168 " --skip-devices [true|false]" +
169 " --push-provider-name [string]" +
170 " --push-provider-type [string]" +
171 " --user-id [string]" +
172 " --output-format [json|tree]",
173 Short: "Test push notifications",
174 Example: heredoc.Doc(`
175 # A test push notification for a certain message id
176 $ stream-cli chat test-push --message-id msgid --user-id id --skip-devices true
177 `),
178 RunE: func(cmd *cobra.Command, args []string) error {
179 c, err := config.GetConfig(cmd).GetClient(cmd)
180 if err != nil {
181 return err
182 }
183
184 msgID, _ := cmd.Flags().GetString("message-id")
185 skipDevices, _ := cmd.Flags().GetBool("skip-devices")
186 pushProviderName, _ := cmd.Flags().GetString("push-provider-name")
187 pushProviderType, _ := cmd.Flags().GetString("push-provider-type")
188 userID, _ := cmd.Flags().GetString("user-id")
189
190 p := &stream_chat.CheckPushRequest{
191 MessageID: msgID,
192 SkipDevices: &skipDevices,
193 PushProviderName: pushProviderName,
194 PushProviderType: pushProviderType,
195 UserID: userID,
196 }
197
198 resp, err := c.CheckPush(cmd.Context(), p)
199 if err != nil {
200 return err
201 }
202
203 return utils.PrintObject(cmd, resp)
204 },
205 }
206
207 fl := cmd.Flags()
208 fl.String("message-id", "", "[optional] Message id to test")
209 fl.Bool("skip-devices", false, "[optional] Whether to notify devices")
210 fl.String("push-provider-name", "", "[optional] Push provider name to use")
211 fl.String("push-provider-type", "", "[optional] Push provider type to use")
212 fl.String("user-id", "", "[optional] User id to initiate the test")
213 fl.StringP("output-format", "o", "json", "[optional] Output format. Can be json or tree")
214
215 return cmd
216}

Callers 1

NewCmdsFunction · 0.85

Calls 4

GetConfigFunction · 0.92
PrintObjectFunction · 0.92
GetClientMethod · 0.80
StringMethod · 0.80

Tested by

no test coverage detected