mysql_bugly_batch_run_test.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package dao
  2. import (
  3. "testing"
  4. "time"
  5. "go-common/app/admin/ep/marthe/model"
  6. "github.com/satori/go.uuid"
  7. . "github.com/smartystreets/goconvey/convey"
  8. )
  9. var (
  10. tmpVersion = time.Now().Format("2006_01_02_15_04_05")
  11. buglyBatchRun = &model.BuglyBatchRun{
  12. BuglyVersionID: 1,
  13. Version: tmpVersion,
  14. BatchID: uuid.NewV4().String(),
  15. RetryCount: 0,
  16. Status: model.BuglyBatchRunStatusRunning,
  17. ErrorMsg: "no",
  18. }
  19. queryBuglyBatchRunsRequest = &model.QueryBuglyBatchRunsRequest{
  20. Pagination: model.Pagination{
  21. PageSize: 10,
  22. PageNum: 1,
  23. },
  24. Version: tmpVersion,
  25. }
  26. )
  27. func Test_Bugly_batch_run(t *testing.T) {
  28. Convey("test insert bugly batch run", t, func() {
  29. err := d.InsertBuglyBatchRun(buglyBatchRun)
  30. So(err, ShouldBeNil)
  31. })
  32. Convey("test update bugly batch run", t, func() {
  33. buglyBatchRun.Status = model.BuglyBatchRunStatusDone
  34. err := d.UpdateBuglyBatchRun(buglyBatchRun)
  35. So(err, ShouldBeNil)
  36. })
  37. Convey("test Find Bugly Batch Runs", t, func() {
  38. buglyBatchRun.Status = model.BuglyBatchRunStatusDone
  39. total, buglyBatchRuns, err := d.FindBuglyBatchRuns(queryBuglyBatchRunsRequest)
  40. So(err, ShouldBeNil)
  41. So(total, ShouldEqual, 1)
  42. So(buglyBatchRun.BatchID, ShouldEqual, buglyBatchRuns[0].BatchID)
  43. })
  44. Convey("test Find Last Success Batch Run By Version", t, func() {
  45. tmpBuglyBatchRun, err := d.QueryLastSuccessBatchRunByVersion(tmpVersion)
  46. So(err, ShouldBeNil)
  47. So(buglyBatchRun.BatchID, ShouldEqual, tmpBuglyBatchRun.BatchID)
  48. })
  49. }