notice_test.go 957 B

12345678910111213141516171819202122232425262728293031
  1. package service
  2. import (
  3. "testing"
  4. "go-common/app/interface/openplatform/article/model"
  5. . "github.com/smartystreets/goconvey/convey"
  6. )
  7. func Test_Notice(t *testing.T) {
  8. a := &model.Notice{ID: 1, Plat: _platAll, Condition: _equal, Build: 20}
  9. b := &model.Notice{ID: 2, Plat: _platIOS, Condition: _greaterThanOrEqual, Build: 30}
  10. c := &model.Notice{ID: 3, Plat: _platAndroid, Condition: _lessThanOrEqual, Build: 50}
  11. s.notices = []*model.Notice{a, b, c}
  12. Convey("all plat", t, func() {
  13. So(s.Notice("", 20), ShouldResemble, a)
  14. So(s.Notice("", 30), ShouldBeNil)
  15. So(s.Notice("", 10), ShouldBeNil)
  16. })
  17. Convey("ios plat", t, func() {
  18. So(s.Notice("ios", 25), ShouldBeNil)
  19. So(s.Notice("ios", 30), ShouldResemble, b)
  20. So(s.Notice("ios", 40), ShouldResemble, b)
  21. })
  22. Convey("android plat", t, func() {
  23. So(s.Notice("android", 25), ShouldResemble, c)
  24. So(s.Notice("android", 50), ShouldResemble, c)
  25. So(s.Notice("android", 60), ShouldBeNil)
  26. })
  27. }