data_test.go 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. package mcndao
  2. import (
  3. "testing"
  4. "time"
  5. "go-common/app/interface/main/mcn/model/mcnmodel"
  6. "github.com/jinzhu/gorm"
  7. "github.com/smartystreets/goconvey/convey"
  8. )
  9. func TestMcndaoGetMcnDataSummary(t *testing.T) {
  10. convey.Convey("GetMcnDataSummary", t, func(ctx convey.C) {
  11. var (
  12. selec = "*"
  13. query = "1=?"
  14. args = "1"
  15. )
  16. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  17. res, err := d.GetMcnDataSummary(selec, query, args)
  18. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  19. ctx.So(err, convey.ShouldBeNil)
  20. ctx.So(res, convey.ShouldNotBeNil)
  21. })
  22. })
  23. })
  24. }
  25. func TestMcndaoGetMcnDataSummaryWithDiff(t *testing.T) {
  26. convey.Convey("GetMcnDataSummaryWithDiff", t, func(ctx convey.C) {
  27. var (
  28. signID = int64(0)
  29. dataTYpe mcnmodel.McnDataType
  30. generateDate = time.Now()
  31. )
  32. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  33. res, err := d.GetMcnDataSummaryWithDiff(signID, dataTYpe, generateDate)
  34. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  35. ctx.So(err, convey.ShouldBeNil)
  36. ctx.So(res, convey.ShouldBeNil)
  37. })
  38. })
  39. })
  40. }
  41. func TestMcndaoGetDataUpLatestDate(t *testing.T) {
  42. convey.Convey("GetDataUpLatestDate", t, func(ctx convey.C) {
  43. var (
  44. dataType = mcnmodel.DataType(1)
  45. )
  46. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  47. generateDate, err := d.GetDataUpLatestDate(dataType, 0)
  48. ctx.Convey("Then err should be nil.generateDate should not be nil.", func(ctx convey.C) {
  49. ctx.So(err, convey.ShouldEqual, gorm.ErrRecordNotFound)
  50. ctx.So(generateDate, convey.ShouldNotBeNil)
  51. })
  52. })
  53. })
  54. }
  55. func TestMcndaoGetAllUpData(t *testing.T) {
  56. convey.Convey("GetAllUpData", t, func(ctx convey.C) {
  57. var (
  58. signID = int64(0)
  59. upmid = int64(0)
  60. generateDate = time.Now()
  61. )
  62. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  63. res, err := d.GetAllUpData(signID, upmid, generateDate)
  64. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  65. ctx.So(err, convey.ShouldBeNil)
  66. ctx.So(res, convey.ShouldNotBeNil)
  67. })
  68. })
  69. })
  70. }
  71. func TestMcndaoGetAllUpDataTemp(t *testing.T) {
  72. convey.Convey("GetAllUpDataTemp", t, func(ctx convey.C) {
  73. var (
  74. signID = int64(0)
  75. upmid = int64(0)
  76. generateDate = time.Now()
  77. )
  78. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  79. res, err := d.GetAllUpDataTemp(signID, upmid, generateDate)
  80. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  81. ctx.So(err, convey.ShouldBeNil)
  82. ctx.So(res, convey.ShouldNotBeNil)
  83. })
  84. })
  85. })
  86. }