dao_test.go 830 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package account
  2. import (
  3. "context"
  4. "encoding/json"
  5. "flag"
  6. "fmt"
  7. "path/filepath"
  8. "testing"
  9. "time"
  10. "go-common/app/admin/main/feed/conf"
  11. "go-common/library/ecode"
  12. . "github.com/smartystreets/goconvey/convey"
  13. )
  14. var (
  15. d *Dao
  16. )
  17. func init() {
  18. dir, _ := filepath.Abs("../../cmd/feed-admin-test.toml")
  19. flag.Set("conf", dir)
  20. conf.Init()
  21. d = New(conf.Conf)
  22. time.Sleep(5 * time.Second)
  23. }
  24. func Test_Card(t *testing.T) {
  25. Convey("Card", t, func() {
  26. acc, err := d.Card3(context.TODO(), 400062)
  27. if err != nil {
  28. if err.Error() == ecode.MemberNotExist.Error() {
  29. fmt.Println("MemberNotExist")
  30. return
  31. }
  32. }
  33. So(err, ShouldBeNil)
  34. v, err := json.Marshal(acc)
  35. if err != nil {
  36. fmt.Printf("%v", err)
  37. return
  38. }
  39. if v == nil {
  40. fmt.Println("empty value")
  41. } else {
  42. fmt.Println(string(v))
  43. }
  44. })
  45. }