(t *testing.T)
| 474 | } |
| 475 | |
| 476 | func 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 | |
| 510 | func TestSaveImageFile(t *testing.T) { |
| 511 | fpath := filepath.Join(os.TempDir(), "files") |
nothing calls this directly
no test coverage detected