contract_test.go 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/service/main/tv/internal/model"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaoUserContractByMid(t *testing.T) {
  9. convey.Convey("UserContractByMid", t, func(ctx convey.C) {
  10. var (
  11. c = context.Background()
  12. mid = int64(27515308)
  13. )
  14. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  15. uc, err := d.UserContractByMid(c, mid)
  16. ctx.Convey("Then err should be nil.uc should not be nil.", func(ctx convey.C) {
  17. ctx.So(err, convey.ShouldBeNil)
  18. ctx.So(uc, convey.ShouldNotBeNil)
  19. })
  20. })
  21. })
  22. }
  23. func TestDaoUserContractByContractId(t *testing.T) {
  24. convey.Convey("UserContractByContractId", t, func(ctx convey.C) {
  25. var (
  26. c = context.Background()
  27. contractId = "Wx45678934567893456789"
  28. )
  29. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  30. uc, err := d.UserContractByContractId(c, contractId)
  31. ctx.Convey("Then err should be nil.uc should not be nil.", func(ctx convey.C) {
  32. ctx.So(err, convey.ShouldBeNil)
  33. ctx.So(uc, convey.ShouldNotBeNil)
  34. })
  35. })
  36. })
  37. }
  38. func TestDaoTxDeleteUserContract(t *testing.T) {
  39. convey.Convey("TxDeleteUserContract", t, func(ctx convey.C) {
  40. var (
  41. c = context.Background()
  42. tx, _ = d.BeginTran(c)
  43. id = int32(1)
  44. )
  45. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  46. err := d.TxDeleteUserContract(c, tx, id)
  47. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  48. ctx.So(err, convey.ShouldBeNil)
  49. })
  50. })
  51. ctx.Reset(func() {
  52. tx.Commit()
  53. })
  54. })
  55. }
  56. func TestDaoTxInsertUserContract(t *testing.T) {
  57. convey.Convey("TxInsertUserContract", t, func(ctx convey.C) {
  58. var (
  59. c = context.Background()
  60. tx, _ = d.BeginTran(c)
  61. uc = &model.UserContract{
  62. Mid: 27515308,
  63. ContractId: "Wx45678934567893456789",
  64. OrderNo: "T234567890456789",
  65. }
  66. )
  67. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  68. id, err := d.TxInsertUserContract(c, tx, uc)
  69. ctx.Convey("Then err should be nil.id should not be nil.", func(ctx convey.C) {
  70. ctx.So(err, convey.ShouldBeNil)
  71. ctx.So(id, convey.ShouldNotBeNil)
  72. })
  73. })
  74. ctx.Reset(func() {
  75. tx.Commit()
  76. })
  77. })
  78. }