task_test.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package archive
  2. import (
  3. "context"
  4. . "github.com/smartystreets/goconvey/convey"
  5. "go-common/app/admin/main/videoup/model/archive"
  6. "testing"
  7. "time"
  8. )
  9. func Test_Weight(t *testing.T) {
  10. cfg, boolean, err := archive.ParseWeightConf(&archive.WeightConf{
  11. Radio: archive.WConfTaskID,
  12. Ids: "1,2,3,4,5",
  13. Rule: 0,
  14. Weight: 15,
  15. Desc: "测试taskid权重配置",
  16. }, 10086, "cxf")
  17. if err != nil || cfg == nil || !boolean {
  18. t.Fatalf("err %+v cfg:%+v bool:%v\n", err, cfg, boolean)
  19. }
  20. if err = d.InWeightConf(context.TODO(), cfg); err != nil {
  21. t.Fatal(err)
  22. }
  23. }
  24. func Test_MulAddTaskHis(t *testing.T) {
  25. row, err := d.MulAddTaskHis(context.TODO(), []*archive.TaskForLog{
  26. &archive.TaskForLog{
  27. ID: 1,
  28. Cid: 2,
  29. Subject: 0,
  30. Mtime: time.Now(),
  31. }, &archive.TaskForLog{
  32. ID: 2,
  33. Cid: 4,
  34. Subject: 1,
  35. Mtime: time.Now(),
  36. },
  37. }, archive.ActionDispatch, 10086)
  38. if row != 2 || err != nil {
  39. t.Fail()
  40. }
  41. }
  42. func Test_TaskTooksByHalfHour(t *testing.T) {
  43. Convey("test archive", t, WithDao(func(d *Dao) {
  44. _, err := d.TaskTooksByHalfHour(context.Background(), time.Now().Add(-time.Hour), time.Now())
  45. So(err, ShouldBeNil)
  46. }))
  47. }