live_test.go 597 B

123456789101112131415161718192021222324
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestDaoLive(t *testing.T) {
  8. convey.Convey("Live", t, func() {
  9. var (
  10. c = context.Background()
  11. )
  12. convey.Convey("When http request gets code == 0", func(ctx convey.C) {
  13. httpMock("GET", d.liveURI).Reply(200).JSON(`{"code":0,"msg":"ok","message":"ok","data":{"count":770843}}`)
  14. count, err := d.Live(c)
  15. ctx.Convey("Then err should be nil.count should greater 0.", func(ctx convey.C) {
  16. ctx.So(err, convey.ShouldBeNil)
  17. ctx.So(count, convey.ShouldBeGreaterThan, 0)
  18. })
  19. })
  20. })
  21. }