You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

msg_test.go 2.1 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // Copyright © 2023 OpenIM open source community. All rights reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package msg
  15. import (
  16. "fmt"
  17. "testing"
  18. "github.com/openimsdk/openkf/server/pkg/openim/param/request"
  19. "github.com/openimsdk/openkf/server/pkg/openim/sdk/constant"
  20. )
  21. // TestAdminSendMsg test admin send msg function
  22. func TestAdminSendMsg(t *testing.T) {
  23. adminToken := "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VySUQiOiJvcGVuSU1BZG1pbiIsIlBsYXRmb3JtSUQiOjEsImV4cCI6MTY5OTQyNTExMywibmJmIjoxNjkxNjQ4ODEzLCJpYXQiOjE2OTE2NDkxMTN9.JYNly2XpKkZuwZ9t4YTGki2TFst29fQYlmIFQytsoho"
  24. // test case
  25. testData := []struct {
  26. sendID string
  27. recvID string
  28. SenderPlatformID int
  29. content string
  30. contentType int
  31. sessionType int
  32. }{
  33. {
  34. sendID: "555248a1d1409a7abb5830fdad5d",
  35. recvID: "54c09e9a6645bad1c6657dcee887",
  36. SenderPlatformID: constant.PLATFORMID_WEB,
  37. content: "{\"content\":\"hello world!\"}",
  38. contentType: constant.CONTENT_TYPE_TEXT,
  39. sessionType: constant.SESSION_TYPE_SINGLE_CHAT,
  40. },
  41. }
  42. // range test case
  43. for _, data := range testData {
  44. res, err := AdminSendMsg(&request.MsgInfo{
  45. SendID: data.sendID,
  46. RecvID: data.recvID,
  47. SenderPlatformID: data.SenderPlatformID,
  48. Content: &request.TextContent{Text: data.content},
  49. ContentType: data.contentType,
  50. SessionType: data.sessionType,
  51. },
  52. "123123123123123",
  53. "http://127.0.0.1:10002",
  54. adminToken,
  55. )
  56. if err != nil {
  57. t.Error(err)
  58. }
  59. fmt.Printf("%v", res)
  60. }
  61. }