resource_test.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package dao
  2. import (
  3. "context"
  4. "go-common/library/database/sql"
  5. "testing"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaoGetAbleCode(t *testing.T) {
  9. convey.Convey("GetAbleCode", t, func(ctx convey.C) {
  10. var (
  11. tx = &sql.Tx{}
  12. batchCodeID = int64(0)
  13. )
  14. tx, err := d.StartTx(context.Background())
  15. ctx.So(err, convey.ShouldBeNil)
  16. ctx.So(tx, convey.ShouldNotBeNil)
  17. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  18. _, err := d.GetAbleCode(tx, batchCodeID)
  19. ctx.Convey("Then err should be nil.code should not be nil.", func(ctx convey.C) {
  20. ctx.So(err, convey.ShouldBeNil)
  21. })
  22. })
  23. })
  24. }
  25. func TestDaoUpdateCodeRelationID(t *testing.T) {
  26. convey.Convey("UpdateCodeRelationID", t, func(ctx convey.C) {
  27. var (
  28. code = ""
  29. relationID = ""
  30. bmid = int64(0)
  31. )
  32. tx, err := d.StartTx(context.Background())
  33. ctx.So(err, convey.ShouldBeNil)
  34. ctx.So(tx, convey.ShouldNotBeNil)
  35. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  36. err := d.UpdateCodeRelationID(tx, code, relationID, bmid)
  37. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  38. ctx.So(err, convey.ShouldBeNil)
  39. })
  40. })
  41. })
  42. }
  43. func TestDaoSelBatchCodeByID(t *testing.T) {
  44. convey.Convey("SelBatchCodeByID", t, func(ctx convey.C) {
  45. var (
  46. batchCodeID = int64(0)
  47. )
  48. tx, err := d.StartTx(context.Background())
  49. ctx.So(err, convey.ShouldBeNil)
  50. ctx.So(tx, convey.ShouldNotBeNil)
  51. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  52. _, err := d.SelBatchCodeByID(tx, batchCodeID)
  53. ctx.Convey("Then err should be nil.r should not be nil.", func(ctx convey.C) {
  54. ctx.So(err, convey.ShouldBeNil)
  55. })
  56. })
  57. })
  58. }