SimpleCloudNotifier/server/test/message_test.go

35 lines
1.0 KiB
Go
Raw Normal View History

2022-11-30 17:58:04 +01:00
package test
import (
tt "blackforestbytes.com/simplecloudnotifier/test/util"
2022-12-11 02:47:23 +01:00
"fmt"
"github.com/gin-gonic/gin"
"gogs.mikescher.com/BlackForestBytes/goext/langext"
"net/url"
2022-11-30 17:58:04 +01:00
"testing"
)
2022-12-11 02:47:23 +01:00
func TestSearchMessageFTSSimple(t *testing.T) {
2022-11-30 17:58:04 +01:00
ws, stop := tt.StartSimpleWebserver(t)
defer stop()
2022-12-11 02:47:23 +01:00
baseUrl := "http://127.0.0.1:" + ws.Port
2022-11-30 17:58:04 +01:00
2022-12-11 02:47:23 +01:00
data := tt.InitDefaultData(t, ws)
type mglist struct {
Messages []gin.H `json:"messages"`
}
msgList := tt.RequestAuthGet[mglist](t, data.User[0].AdminKey, baseUrl, fmt.Sprintf("/api/messages?filter=%s", url.QueryEscape("Friday")))
tt.AssertEqual(t, "msgList.len", 2, len(msgList.Messages))
tt.AssertTrue(t, "msgList.any<1>", langext.ArrAny(msgList.Messages, func(msg gin.H) bool { return msg["title"].(string) == "Invitation" }))
tt.AssertTrue(t, "msgList.any<2>", langext.ArrAny(msgList.Messages, func(msg gin.H) bool { return msg["title"].(string) == "Important notice" }))
}
func TestSearchMessageFTSMulti(t *testing.T) {
2022-12-09 00:13:10 +01:00
//TODO search for messages by FTS
2022-11-30 21:39:14 +01:00
}
2022-12-09 00:13:10 +01:00
//TODO test missing message-xx methods