mysql_test.go 1011 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package dao
  2. import (
  3. "context"
  4. "math/rand"
  5. "testing"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaoTable(t *testing.T) {
  9. var (
  10. oid = int64(0)
  11. )
  12. convey.Convey("table", t, func(ctx convey.C) {
  13. p1 := table(oid)
  14. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  15. ctx.So(p1, convey.ShouldNotBeNil)
  16. })
  17. })
  18. }
  19. func TestDaoShare(t *testing.T) {
  20. var (
  21. c = context.TODO()
  22. oid = int64(0)
  23. tp = int(0)
  24. )
  25. convey.Convey("Share", t, func(ctx convey.C) {
  26. share, err := d.Share(c, oid, tp)
  27. ctx.Convey("Then err should be nil.share should not be nil.", func(ctx convey.C) {
  28. ctx.So(err, convey.ShouldBeNil)
  29. ctx.So(share, convey.ShouldNotBeNil)
  30. })
  31. })
  32. }
  33. func TestDaoAddShare(t *testing.T) {
  34. var (
  35. c = context.TODO()
  36. oid = int64(rand.Intn(10000000))
  37. tp = int(3)
  38. )
  39. convey.Convey("AddShare", t, func(ctx convey.C) {
  40. err := d.AddShare(c, oid, tp)
  41. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  42. ctx.So(err, convey.ShouldBeNil)
  43. })
  44. })
  45. }