challenge_test.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package service
  2. import (
  3. "context"
  4. "testing"
  5. "time"
  6. "go-common/app/admin/main/workflow/model"
  7. "go-common/app/admin/main/workflow/model/param"
  8. "go-common/app/admin/main/workflow/model/search"
  9. "github.com/smartystreets/goconvey/convey"
  10. )
  11. func TestSetGroupResult(t *testing.T) {
  12. convey.Convey("SetGroupResult", t, func() {
  13. g := new(model.Group)
  14. err := s.dao.ORM.Table("workflow_group").Where("business=1").Find(g).Error
  15. convey.So(err, convey.ShouldBeNil)
  16. err = s.SetGroupResult(context.Background(), &param.GroupResParam{Oid: g.Oid, Business: g.Business, State: int8(1), AdminID: int64(1), Reason: "hhh"})
  17. convey.So(err, convey.ShouldBeNil)
  18. ng := new(model.Group)
  19. err = s.dao.ORM.Table("workflow_group").Where("business=1 and oid=?", g.Oid).Find(ng).Error
  20. convey.So(err, convey.ShouldBeNil)
  21. convey.So(ng.State, convey.ShouldEqual, int8(1))
  22. })
  23. }
  24. func TestChallListCommon(t *testing.T) {
  25. convey.Convey("ChallListCommon", t, func() {
  26. cPage, err := s.ChallListCommon(context.Background(), &search.ChallSearchCommonCond{
  27. Order: "ctime", Sort: "desc", PN: 1, PS: 50})
  28. time.Sleep(3 * time.Second)
  29. convey.So(err, convey.ShouldBeNil)
  30. convey.So(cPage.Page.Total, convey.ShouldBeGreaterThanOrEqualTo, int32(1))
  31. })
  32. }
  33. func TestChallList(t *testing.T) {
  34. convey.Convey("ChallList", t, func() {
  35. cPage, err := s.ChallList(context.Background(), &search.ChallSearchCommonCond{IDs: []int64{1},
  36. PN: 1, PS: 50, Order: "id", Sort: "desc"})
  37. convey.So(err, convey.ShouldBeNil)
  38. convey.So(cPage.Page.Total, convey.ShouldBeGreaterThanOrEqualTo, int32(1))
  39. })
  40. }
  41. func TestChallDetail(t *testing.T) {
  42. convey.Convey("ChallDetail", t, func() {
  43. chall, err := s.ChallDetail(context.Background(), int64(1))
  44. convey.So(err, convey.ShouldBeNil)
  45. convey.So(chall.Cid, convey.ShouldEqual, int32(1))
  46. })
  47. }