You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

33 lines
880 B

package dao
import (
"context"
"testing"
"github.com/smartystreets/goconvey/convey"
)
func TestDaoFullImport(t *testing.T) {
var (
c = context.Background()
build = int(0)
)
convey.Convey("FullImport", t, func(ctx convey.C) {
ctx.Convey("Http code err", func(ctx convey.C) {
httpMock("GET", d.fullURL).Reply(-400).JSON(``)
_, err := d.FullImport(c, build)
ctx.So(err, convey.ShouldNotBeNil)
})
ctx.Convey("Business code err", func(ctx convey.C) {
httpMock("GET", d.fullURL).Reply(200).JSON(`{"code":-400}`)
_, err := d.FullImport(c, build)
ctx.So(err, convey.ShouldNotBeNil)
})
ctx.Convey("Everything goes well", func(ctx convey.C) {
httpMock("GET", d.fullURL).Reply(200).JSON(`{"code":0,"data":[{"id":1}]}`)
data, err := d.FullImport(c, build)
ctx.So(err, convey.ShouldBeNil)
ctx.So(data, convey.ShouldNotBeNil)
})
})
}