notice_test.go 1016 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/admin/main/growup/model"
  6. . "github.com/smartystreets/goconvey/convey"
  7. )
  8. func Test_NoticeSql(t *testing.T) {
  9. Convey("growup-admin", t, WithMysql(func(d *Dao) {
  10. var (
  11. a = &model.Notice{Title: "title", Type: 1, Platform: 1, Link: "www.bilibili.com", Status: 1}
  12. )
  13. _, err := d.InsertNotice(context.Background(), a)
  14. So(err, ShouldBeNil)
  15. }))
  16. Convey("growup-admin", t, WithMysql(func(d *Dao) {
  17. var (
  18. query = ""
  19. )
  20. _, err := d.NoticeCount(context.Background(), query)
  21. So(err, ShouldBeNil)
  22. }))
  23. Convey("growup-admin", t, WithMysql(func(d *Dao) {
  24. var (
  25. query = ""
  26. from, limit = 0, 1000
  27. )
  28. res, err := d.Notices(context.Background(), query, from, limit)
  29. So(err, ShouldBeNil)
  30. So(len(res), ShouldBeGreaterThan, 0)
  31. }))
  32. Convey("growup-admin", t, WithMysql(func(d *Dao) {
  33. var (
  34. kv = "is_deleted = 1"
  35. id int64 = 1
  36. )
  37. _, err := d.UpdateNotice(context.Background(), kv, id)
  38. So(err, ShouldBeNil)
  39. }))
  40. }