2023-08-25 07:37:35 +00:00
|
|
|
package logic
|
|
|
|
|
|
|
|
import (
|
2023-09-04 03:32:17 +00:00
|
|
|
"bytes"
|
2023-08-25 07:37:35 +00:00
|
|
|
"fmt"
|
|
|
|
"fusenapi/utils/wevent"
|
|
|
|
"log"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/474420502/requests"
|
|
|
|
"github.com/google/uuid"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
|
|
)
|
|
|
|
|
2023-09-04 03:32:17 +00:00
|
|
|
func TestEmailTpl(t *testing.T) {
|
|
|
|
data := map[string]string{
|
|
|
|
"CompanyName": "companyName",
|
|
|
|
"ConfirmationLink": "confirmationLink",
|
|
|
|
"SenderName": "senderName",
|
|
|
|
"SenderTitle": "senderTitle",
|
|
|
|
}
|
|
|
|
|
|
|
|
var result bytes.Buffer
|
|
|
|
err := tpls.ExecuteTemplate(&result, "email_register.tpl", data)
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Println(string(result.String()))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-08-25 07:37:35 +00:00
|
|
|
func TestSender(t *testing.T) {
|
|
|
|
traceId := uuid.NewString()
|
|
|
|
event := wevent.NewWebsocketEventSuccess(wevent.UserEmailRegister, traceId)
|
|
|
|
event.Data = wevent.DataEmailRegister{
|
|
|
|
JwtToken: traceId,
|
|
|
|
}
|
|
|
|
|
|
|
|
tp := requests.Post(fmt.Sprintf("%s/api/websocket/common_notify", "https://server.fusen.3718.cn:9900"))
|
|
|
|
tp.SetBodyJson(requests.M{
|
|
|
|
"wid": "tGyMYX9EldtsPLZTyT6PxrRgEV615CQGEiu9Sb1XrjZ4kpTjI46sQyh7kYfVlgN9uR5Uw4KDF+S62IknmaRgSMdee1QHVtCv+VEKrMF76snR04zS1ZbWZCgX5Lv2xgHz/bZBWwJF/9u6YTy2/FetGg==",
|
|
|
|
"data": event,
|
|
|
|
})
|
|
|
|
|
|
|
|
wresp, err := tp.Execute()
|
|
|
|
if err != nil {
|
|
|
|
logx.Error(err, "traceId")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
result := wresp.Json()
|
|
|
|
if result.Get("code").Int() != 200 {
|
|
|
|
logx.Error(result.Get("message"))
|
|
|
|
return
|
|
|
|
}
|
|
|
|
log.Println(result)
|
|
|
|
|
|
|
|
}
|