material_test.go 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestDaoCategoryByID(t *testing.T) {
  8. convey.Convey("CategoryByID", t, func(ctx convey.C) {
  9. var (
  10. c = context.Background()
  11. id = int64(1)
  12. )
  13. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  14. cate, err := d.CategoryByID(c, id)
  15. ctx.Convey("Then err should be nil.cate should not be nil.", func(ctx convey.C) {
  16. ctx.So(err, convey.ShouldBeNil)
  17. ctx.So(cate, convey.ShouldNotBeNil)
  18. })
  19. })
  20. })
  21. }
  22. func TestDaoBindWithCategory(t *testing.T) {
  23. convey.Convey("BindWithCategory", t, func(ctx convey.C) {
  24. var (
  25. c = context.Background()
  26. MaterialID = int64(2)
  27. CategoryID = int64(1)
  28. index = int64(1)
  29. )
  30. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  31. id, err := d.BindWithCategory(c, MaterialID, CategoryID, index)
  32. ctx.Convey("Then err should be nil.id should not be nil.", func(ctx convey.C) {
  33. ctx.So(err, convey.ShouldBeNil)
  34. ctx.So(id, convey.ShouldNotBeNil)
  35. })
  36. })
  37. })
  38. }