version_test.go 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/service/openplatform/ticket-item/model"
  6. . "github.com/smartystreets/goconvey/convey"
  7. )
  8. // TestAddVersion
  9. func TestDao_AddVersion(t *testing.T) {
  10. Convey("AddVersion", t, func() {
  11. once.Do(startService)
  12. err := d.AddVersion(context.TODO(), nil, &model.Version{
  13. Type: 2,
  14. Status: 1, // 审核中
  15. ItemName: "gotest",
  16. ParentID: 10164,
  17. TargetItem: 0,
  18. AutoPub: 1, // 自动上架
  19. }, &model.VersionExt{
  20. Type: 1,
  21. MainInfo: "{'name':'公告test','introduction':'公告简介','content':'公告内容','pid':10164,'project_name':'删通票删票种'}",
  22. })
  23. So(err, ShouldBeNil)
  24. })
  25. }
  26. // TestUpdateVersion
  27. func TestDao_UpdateVersion(t *testing.T) {
  28. Convey("UpdateVersion", t, func() {
  29. once.Do(startService)
  30. res, err := d.UpdateVersion(context.TODO(), &model.Version{
  31. VerID: 2691387070776769288,
  32. Type: 2,
  33. Status: 2, // 审核中
  34. ItemName: "gotest公告",
  35. ParentID: 0,
  36. TargetItem: 10164,
  37. AutoPub: 1, // 自动上架
  38. })
  39. So(res, ShouldBeTrue)
  40. So(err, ShouldBeNil)
  41. })
  42. }
  43. // TestGetVersion
  44. func TestDao_GetVersion(t *testing.T) {
  45. Convey("GetVersion", t, func() {
  46. once.Do(startService)
  47. verInfo, verExtInfo, err := d.GetVersion(context.TODO(), 153008633987459678, true)
  48. So(verInfo, ShouldNotBeNil)
  49. So(verExtInfo, ShouldNotBeNil)
  50. So(err, ShouldBeNil)
  51. })
  52. }
  53. // TestRejectVersion
  54. func TestDao_RejectVersion(t *testing.T) {
  55. Convey("RejectVersion", t, func() {
  56. once.Do(startService)
  57. res, err := d.RejectVersion(context.TODO(), 2691387070776769288, 2)
  58. So(res, ShouldBeTrue)
  59. So(err, ShouldBeNil)
  60. })
  61. }
  62. // TestAddVersionLog
  63. func TestDao_AddVersionLog(t *testing.T) {
  64. Convey("AddVersionLog", t, func() {
  65. once.Do(startService)
  66. err := d.AddVersionLog(context.TODO(), &model.VersionLog{
  67. VerID: 2691387070776769288,
  68. Type: 1,
  69. Log: "reject",
  70. IsPass: 0,
  71. Uname: "tester",
  72. })
  73. So(err, ShouldBeNil)
  74. })
  75. }