users_test.go 823 B

12345678910111213141516171819202122232425262728293031
  1. package service
  2. import (
  3. "context"
  4. "testing"
  5. . "github.com/smartystreets/goconvey/convey"
  6. )
  7. func Test_UpdateUserNoticeState(t *testing.T) {
  8. Convey("update state", t, func() {
  9. err := s.UpdateUserNoticeState(context.TODO(), 100, "lead")
  10. So(err, ShouldBeNil)
  11. Convey("get lead data", func() {
  12. res, err := s.UserNoticeState(context.TODO(), 100)
  13. So(err, ShouldBeNil)
  14. So(res["lead"], ShouldBeTrue)
  15. })
  16. Convey("update new and get lead data", func() {
  17. err := s.UpdateUserNoticeState(context.TODO(), 100, "new")
  18. res, err := s.UserNoticeState(context.TODO(), 100)
  19. So(err, ShouldBeNil)
  20. So(res["lead"], ShouldBeTrue)
  21. So(res["new"], ShouldBeTrue)
  22. })
  23. })
  24. Convey("update invalid state", t, func() {
  25. err := s.UpdateUserNoticeState(context.TODO(), 100, "invalid")
  26. So(err, ShouldNotBeNil)
  27. })
  28. }