From 91a6808ad2603b8150eba1cdb572b1c474025cdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Wed, 30 Nov 2022 20:47:43 +0100 Subject: [PATCH] Tests[SendWithSendername] --- server/test/message_test.go | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/server/test/message_test.go b/server/test/message_test.go index 8747a12..5f42634 100644 --- a/server/test/message_test.go +++ b/server/test/message_test.go @@ -227,7 +227,38 @@ func TestSendContentMessage(t *testing.T) { tt.AssertStrRepEqual(t, "msg.scn_msg_id", msg1["scn_msg_id"], pusher.Last().Message.SCNMessageID) } -//TODO sendername +func TestSendWithSendername(t *testing.T) { + ws, stop := tt.StartSimpleWebserver(t) + defer stop() + + pusher := ws.Pusher.(*push.TestSink) + + baseUrl := "http://127.0.0.1:" + ws.Port + + r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/users", gin.H{ + "agent_model": "DUMMY_PHONE", + "agent_version": "4X", + "client_type": "ANDROID", + "fcm_token": "DUMMY_FCM", + }) + + uid := int(r0["user_id"].(float64)) + sendtok := r0["send_key"].(string) + + msg1 := tt.RequestPost[gin.H](t, baseUrl, "/", gin.H{ + "user_key": sendtok, + "user_id": uid, + "title": "HelloWorld_xyz", + "content": "Unicode: 日本 - yäy\000\n\t\x00...", + "sender_name": "localhorst", + }) + + tt.AssertEqual(t, "messageCount", 1, len(pusher.Data)) + tt.AssertStrRepEqual(t, "msg.title", "HelloWorld_xyz", pusher.Last().Message.Title) + tt.AssertStrRepEqual(t, "msg.content", "Unicode: 日本 - yäy\000\n\t\x00...", pusher.Last().Message.Content) + tt.AssertStrRepEqual(t, "msg.SenderName", "localhorst", pusher.Last().Message.SenderName) + tt.AssertStrRepEqual(t, "msg.scn_msg_id", msg1["scn_msg_id"], pusher.Last().Message.SCNMessageID) +} //TODO trim too-long content