member_old_test.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestDaoAccounts(t *testing.T) {
  8. convey.Convey("Accounts", t, func(convCtx convey.C) {
  9. var (
  10. c = context.Background()
  11. mids = []int64{1, 2}
  12. )
  13. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  14. accs, errs, err := d.Accounts(c, mids)
  15. if err != nil {
  16. convCtx.Convey("When no rows int result", func(convCtx convey.C) {
  17. convCtx.So(err, convey.ShouldNotBeNil)
  18. convCtx.So(errs, convey.ShouldNotBeNil)
  19. convCtx.So(accs, convey.ShouldNotBeNil)
  20. })
  21. } else {
  22. convCtx.Convey("When have rows int result", func(convCtx convey.C) {
  23. convCtx.So(err, convey.ShouldBeNil)
  24. convCtx.So(errs, convey.ShouldNotBeNil)
  25. convCtx.So(accs, convey.ShouldNotBeNil)
  26. })
  27. }
  28. })
  29. })
  30. }
  31. func TestDaoName(t *testing.T) {
  32. convey.Convey("Name", t, func(convCtx convey.C) {
  33. var (
  34. c = context.Background()
  35. mid = int64(1)
  36. )
  37. convCtx.Convey("Name search two situation:", func(convCtx convey.C) {
  38. name, err := d.Name(c, mid)
  39. if err != nil {
  40. convCtx.Convey("Name occur an error", func(convCtx convey.C) {
  41. convCtx.So(err, convey.ShouldNotBeNil)
  42. convCtx.So(name, convey.ShouldNotBeNil)
  43. })
  44. } else {
  45. convCtx.Convey("Name no err search", func(convCtx convey.C) {
  46. convCtx.So(err, convey.ShouldBeNil)
  47. convCtx.So(name, convey.ShouldNotBeNil)
  48. })
  49. }
  50. })
  51. })
  52. }