dao_test.go 814 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package archive
  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_Archive3(t *testing.T) {
  25. Convey("Card", t, func() {
  26. arc, err := d.Archive3(context.TODO(), 10099667)
  27. if err != nil {
  28. if err == ecode.NothingFound {
  29. fmt.Println("NothingFound")
  30. return
  31. }
  32. }
  33. So(err, ShouldBeNil)
  34. v, err := json.Marshal(arc)
  35. if err != nil {
  36. fmt.Println(err)
  37. return
  38. }
  39. if v == nil {
  40. fmt.Println("empty value")
  41. } else {
  42. fmt.Println(string(v))
  43. }
  44. })
  45. }