service_test.go 824 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package service
  2. import (
  3. "testing"
  4. "go-common/app/job/main/broadcast/conf"
  5. . "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestNewService(t *testing.T) {
  8. Convey("TestNewService", t, func() {
  9. s := New(conf.Conf)
  10. So(s, ShouldNotBeNil)
  11. Convey("TestPush", func() {
  12. err := s.pushMsg([]byte("test"))
  13. So(err, ShouldBeNil)
  14. })
  15. Convey("TestPushComet", func() {
  16. s.pushKeys(1, "test", nil, []byte("test"), 0)
  17. })
  18. Convey("TestBroadCast", func() {
  19. s.broadcast(1, []byte("test"), 100, "", 0)
  20. })
  21. Convey("TestBroadCast", func() {
  22. s.broadcastRoomRawBytes("1", []byte("test"))
  23. })
  24. Convey("TestNewRoom", func() {
  25. r := NewRoom(s, "test", RoomOptions{})
  26. So(r, ShouldNotBeNil)
  27. Convey("TestNewPush", func() {
  28. err := r.Push(7, []byte("test"), 0)
  29. So(err, ShouldBeNil)
  30. })
  31. })
  32. })
  33. }