live_test.go 847 B

123456789101112131415161718192021222324252627282930313233
  1. package dao
  2. import (
  3. "context"
  4. "go-common/library/ecode"
  5. "testing"
  6. "github.com/smartystreets/goconvey/convey"
  7. "gopkg.in/h2non/gock.v1"
  8. )
  9. func TestDao_Live(t *testing.T) {
  10. convey.Convey("test live", t, func(ctx convey.C) {
  11. defer gock.OffAll()
  12. httpMock("GET", d.liveURL).Reply(200).JSON(`{"code": 0}`)
  13. mid := int64(28272030)
  14. platform := "ios"
  15. data, err := d.Live(context.Background(), mid, platform)
  16. convey.So(err, convey.ShouldBeNil)
  17. convey.Printf("%v", data)
  18. })
  19. }
  20. func TestDao_LiveMetal(t *testing.T) {
  21. convey.Convey("test live metal", t, func(ctx convey.C) {
  22. defer gock.OffAll()
  23. httpMock("GET", d.liveMetalURL).Reply(200).JSON(`{"code": 510002}`)
  24. mid := int64(28272030)
  25. data, err := d.LiveMetal(context.Background(), mid)
  26. convey.So(err, convey.ShouldEqual, ecode.Int(510002))
  27. convey.Printf("%v", data)
  28. })
  29. }