123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- package growup
- import (
- "context"
- "go-common/library/ecode"
- "testing"
- "github.com/smartystreets/goconvey/convey"
- )
- func TestGrowupUpStatus(t *testing.T) {
- var (
- c = context.TODO()
- mid = int64(2089809)
- ip = "127.0.0.1"
- )
- convey.Convey("UpStatus", t, func(ctx convey.C) {
- us, err := d.UpStatus(c, mid, ip)
- ctx.Convey("Then err should be nil.us should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldEqual, ecode.CreativeOrderAPIErr)
- ctx.So(us, convey.ShouldNotBeNil)
- })
- })
- }
- func TestGrowupUpInfo(t *testing.T) {
- var (
- c = context.TODO()
- mid = int64(2089809)
- ip = "127.0.0.1"
- )
- convey.Convey("UpInfo", t, func(ctx convey.C) {
- ui, err := d.UpInfo(c, mid, ip)
- ctx.Convey("Then err should be nil.ui should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldNotBeNil)
- ctx.So(ui, convey.ShouldBeNil)
- })
- })
- }
- func TestGrowupJoin(t *testing.T) {
- var (
- c = context.TODO()
- mid = int64(0)
- accTy = int(0)
- signTy = int(0)
- ip = ""
- )
- convey.Convey("Join", t, func(ctx convey.C) {
- err := d.Join(c, mid, accTy, signTy, ip)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldEqual, ecode.CreativeOrderAPIErr)
- })
- })
- }
- func TestGrowupQuit(t *testing.T) {
- var (
- c = context.TODO()
- mid = int64(2089809)
- ip = "127.0.0.1"
- )
- convey.Convey("Quit1", t, func(ctx convey.C) {
- httpMock("POST", d.quitURL).Reply(200).JSON(`{"code":20008}`)
- err := d.Quit(c, mid, ip)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldNotBeNil)
- })
- })
- convey.Convey("Quit2", t, func(ctx convey.C) {
- httpMock("POST", d.quitURL).Reply(502)
- err := d.Quit(c, mid, ip)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldNotBeNil)
- })
- })
- }
- func TestGrowupSummary(t *testing.T) {
- var (
- c = context.TODO()
- mid = int64(2089809)
- ip = "127.0.0.1"
- )
- convey.Convey("Summary", t, func(ctx convey.C) {
- sm, err := d.Summary(c, mid, ip)
- ctx.Convey("Then err should be nil.sm should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldEqual, ecode.CreativeOrderAPIErr)
- ctx.So(sm, convey.ShouldBeNil)
- })
- })
- }
- func TestGrowupStat(t *testing.T) {
- var (
- c = context.TODO()
- mid = int64(2089809)
- ip = "127.0.0.1"
- )
- convey.Convey("Stat", t, func(ctx convey.C) {
- st, err := d.Stat(c, mid, ip)
- ctx.Convey("Then err should be nil.st should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldEqual, ecode.CreativeOrderAPIErr)
- ctx.So(st, convey.ShouldBeNil)
- })
- })
- }
- func TestGrowupIncomeList(t *testing.T) {
- var (
- c = context.TODO()
- mid = int64(2089809)
- ty = int(0)
- pn = int(1)
- ps = int(10)
- ip = "127.0.0.1"
- )
- convey.Convey("IncomeList", t, func(ctx convey.C) {
- il, err := d.IncomeList(c, mid, ty, pn, ps, ip)
- ctx.Convey("Then err should be nil.il should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldEqual, ecode.CreativeOrderAPIErr)
- ctx.So(il, convey.ShouldBeNil)
- })
- })
- }
- func TestGrowupBreachList(t *testing.T) {
- var (
- c = context.TODO()
- mid = int64(2089809)
- pn = int(1)
- ps = int(10)
- ip = "127.0.0.1"
- )
- convey.Convey("BreachList", t, func(ctx convey.C) {
- bl, err := d.BreachList(c, mid, pn, ps, ip)
- ctx.Convey("Then err should be nil.bl should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldEqual, ecode.CreativeOrderAPIErr)
- ctx.So(bl, convey.ShouldBeNil)
- })
- })
- }
|