MCPcopy Create free account
hub / github.com/chanify/chanify / TestSendMsg

Function TestSendMsg

core/sender_test.go:476–508  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

474}
475
476func TestSendMsg(t *testing.T) {
477 c := New()
478 defer c.Close()
479 c.Init(&logic.Options{DBUrl: "sqlite://?mode=memory", Registerable: true}) // nolint: errcheck
480 w := httptest.NewRecorder()
481 tk, _ := model.ParseToken("EiJBQk9PNlRTSVhLU0VWSUpLWExEUVNVWFFSWFVBT1hHR1lZIgRjaGFuKgVNRlJHRw..c2lnbg") // nolint: errcheck
482 ctx, _ := gin.CreateTestContext(w)
483 ctx.Request, _ = http.NewRequest("GET", "", nil)
484 c.sendMsg(ctx, tk, model.NewMessage(tk).TextContent("123", "title", "abc", "1").SetPriority(5))
485 if w.Result().StatusCode != http.StatusBadRequest {
486 t.Fatal("Check invalid user failed")
487 }
488
489 logic.APIEndpoint = "http://127.0.0.1"
490 w = httptest.NewRecorder()
491 ctx, _ = gin.CreateTestContext(w)
492 ctx.Request, _ = http.NewRequest("GET", "", nil)
493 c.logic.UpsertUser("ABOO6TSIXKSEVIJKXLDQSUXQRXUAOXGGYY", "BGaP1ekObDB0bRkmvxkvfFXCLSk46mO7rW8PikP8sWsA_97yij0s0U7ioA9dWEoz41TrUP8Z88XzQ_Tl8AOoJF4", true) // nolint: errcheck
494 c.sendMsg(ctx, tk, model.NewMessage(tk).TextContent("123", "title", "abc", "1"))
495 if w.Result().StatusCode != http.StatusInternalServerError {
496 t.Fatal("Check send serverless failed")
497 }
498
499 logic.MockPusher = &MockAPNSPusher{}
500 w = httptest.NewRecorder()
501 ctx, _ = gin.CreateTestContext(w)
502 ctx.Request, _ = http.NewRequest("GET", "", nil)
503 c.logic.UpsertUser("ABOO6TSIXKSEVIJKXLDQSUXQRXUAOXGGYY", "BGaP1ekObDB0bRkmvxkvfFXCLSk46mO7rW8PikP8sWsA_97yij0s0U7ioA9dWEoz41TrUP8Z88XzQ_Tl8AOoJF4", false) // nolint: errcheck
504 c.sendMsg(ctx, tk, model.NewMessage(tk).TextContent("123", "title", "abc", "1").SetPriority(5))
505 if w.Result().StatusCode != http.StatusNotFound {
506 t.Fatal("Check send serverful failed")
507 }
508}
509
510func TestSaveImageFile(t *testing.T) {
511 fpath := filepath.Join(os.TempDir(), "files")

Callers

nothing calls this directly

Calls 9

ParseTokenFunction · 0.92
NewMessageFunction · 0.92
NewFunction · 0.85
InitMethod · 0.80
sendMsgMethod · 0.80
SetPriorityMethod · 0.80
TextContentMethod · 0.80
CloseMethod · 0.65
UpsertUserMethod · 0.65

Tested by

no test coverage detected