mysql_transfer_test.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. . "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestInsertTransferJob(t *testing.T) {
  8. var (
  9. from, to, mid int64 = 1, 2, 3
  10. offset = 1.11
  11. )
  12. Convey("insert a transfer job to mysql", t, func() {
  13. _, err := testDao.InsertTransferJob(context.TODO(), from, to, mid, offset, 0)
  14. So(err, ShouldBeNil)
  15. })
  16. }
  17. func TestTransferList(t *testing.T) {
  18. var cid, state int64 = 2, 3
  19. Convey("test transfer job list ", t, func() {
  20. res, _, err := testDao.TransferList(context.TODO(), cid, state, 1, 20)
  21. So(err, ShouldBeNil)
  22. So(res, ShouldNotBeNil)
  23. })
  24. }
  25. func TestCheckTransferID(t *testing.T) {
  26. var (
  27. c = context.TODO()
  28. id int64 = 265
  29. )
  30. Convey("test check trans by id", t, func() {
  31. _, err := testDao.CheckTransferID(c, id)
  32. So(err, ShouldBeNil)
  33. })
  34. }
  35. func TestSetTransferState(t *testing.T) {
  36. var (
  37. c = context.TODO()
  38. id int64 = 265
  39. state int8
  40. )
  41. Convey("test change transfer job state", t, func() {
  42. _, err := testDao.SetTransferState(c, id, state)
  43. So(err, ShouldBeNil)
  44. })
  45. }