123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313 |
- package up
- import (
- "context"
- "testing"
- "go-common/app/admin/main/mcn/model"
- xtime "go-common/library/time"
- "github.com/smartystreets/goconvey/convey"
- "gopkg.in/h2non/gock.v1"
- )
- func TestUpMcnDataOverview(t *testing.T) {
- convey.Convey("McnDataOverview", t, func(ctx convey.C) {
- var (
- c = context.Background()
- date = xtime.Time(1542124800)
- )
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- m, err := d.McnDataOverview(c, date)
- ctx.Convey("Then err should be nil.m should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(m, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestUpMcnRankFansOverview(t *testing.T) {
- convey.Convey("McnRankFansOverview", t, func(ctx convey.C) {
- var (
- c = context.Background()
- dataType = model.DataType(2)
- date = xtime.Time(1542124800)
- topLen = int(5)
- )
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- mrf, mids, err := d.McnRankFansOverview(c, dataType, date, topLen)
- ctx.Convey("Then err should be nil.mrf,mids should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(mids, convey.ShouldBeNil)
- ctx.So(mrf, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestUpMcnRankArchiveLikesOverview(t *testing.T) {
- convey.Convey("McnRankArchiveLikesOverview", t, func(ctx convey.C) {
- var (
- c = context.Background()
- dataType = model.DataType(2)
- date = xtime.Time(1542124800)
- topLen = int(5)
- )
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- ras, mids, avids, tids, err := d.McnRankArchiveLikesOverview(c, dataType, date, topLen)
- ctx.Convey("Then err should be nil.ras,mids,avids,tids should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(tids, convey.ShouldBeNil)
- ctx.So(avids, convey.ShouldBeNil)
- ctx.So(mids, convey.ShouldBeNil)
- ctx.So(ras, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestUpMcnDataTypeSummary(t *testing.T) {
- convey.Convey("McnDataTypeSummary", t, func(ctx convey.C) {
- var (
- c = context.Background()
- date = xtime.Time(1542124800)
- )
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- mmd, tids, err := d.McnDataTypeSummary(c, date)
- ctx.Convey("Then err should be nil.mmd,tids should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(tids, convey.ShouldBeNil)
- ctx.So(mmd, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestUpArcTopDataStatistics(t *testing.T) {
- convey.Convey("ArcTopDataStatistics", t, func(ctx convey.C) {
- var (
- c = context.Background()
- arg = &model.McnGetRankReq{}
- )
- arg.SignID = 214
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- defer gock.OffAll()
- result := `
- {
- "message":"0",
- "code":0,
- "data":{
- "type_list":[
- {
- "tid":1,
- "name":"视频"
- }
- ],
- "result":[
- {
- "data_type":1,
- "likes_increase":13,
- "likes_accumulate":13,
- "play_increase":7,
- "archive_id":10110514,
- "archive_title":"不同清晰度",
- "pic":"http://i1.hdslb.com/bfs/archive/3348cb2cb34423f936916444a0a77e59f9daf1d",
- "tid_name":"日常",
- "tid":21,
- "ctime":1535362150,
- "author":{
- "face":"http://static.hdslb.com/images/member/noface.gif",
- "mid":27515266,
- "name":"Testeew还觉得是发货"
- },
- "stat":{
- "view":0
- }
- }
- ]
- },
- "ttl":1
- }`
- httpMock("GET", d.arcTopURL).Reply(200).JSON(result)
- reply, err := d.ArcTopDataStatistics(c, arg)
- ctx.Convey("Then err should be nil.reply should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(reply, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestUpDataFans(t *testing.T) {
- convey.Convey("DataFans", t, func(ctx convey.C) {
- var (
- c = context.Background()
- arg = &model.McnCommonReq{SignID: 1}
- )
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- defer gock.OffAll()
- result := `{
- "message":"",
- "code":0,
- "data":{
- "fans_all":0,
- "fans_inc":0,
- "act_fans":0,
- "fans_dec_all":0,
- "fans_dec":0,
- "view_fans_rate":0,
- "act_fans_rate":0,
- "reply_fans_rate":0,
- "danmu_fans_rate":0,
- "coin_fans_rate":0,
- "like_fans_rate":0,
- "fav_fans_rate":0,
- "share_fans_rate":0,
- "live_gift_fans_rate":0,
- "live_danmu_fans_rate":0
- }
- }`
- httpMock("GET", d.dataFansURL).Reply(200).JSON(result)
- reply, err := d.DataFans(c, arg)
- ctx.Convey("Then err should be nil.reply should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(reply, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestUpDataFansBaseAttr(t *testing.T) {
- convey.Convey("DataFansBaseAttr", t, func(ctx convey.C) {
- var (
- c = context.Background()
- arg = &model.McnCommonReq{SignID: 1}
- )
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- defer gock.OffAll()
- result := `{
- "message":"",
- "code":0,
- "data":{
- "fans_sex":{
- "male":0,
- "female":0
- },
- "fans_age":{
- "a":0,
- "b":0,
- "c":0,
- "d":0
- },
- "fans_play_way":{
- "app":0,
- "pc":0,
- "outside":0,
- "other":0
- }
- }
- }`
- httpMock("GET", d.dataFansBaseAttrURL).Reply(200).JSON(result)
- sex, age, playWay, err := d.DataFansBaseAttr(c, arg)
- ctx.Convey("Then err should be nil.sex,age,playWay should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(playWay, convey.ShouldNotBeNil)
- ctx.So(age, convey.ShouldNotBeNil)
- ctx.So(sex, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestUpDataFansArea(t *testing.T) {
- convey.Convey("DataFansArea", t, func(ctx convey.C) {
- var (
- c = context.Background()
- arg = &model.McnCommonReq{SignID: 1}
- )
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- defer gock.OffAll()
- result := `{
- "message":"",
- "code":0,
- "data":{
- "result":[
- {
- "province":"",
- "user":0
- }
- ]
- }
- }`
- httpMock("GET", d.dataFansAreaURL).Reply(200).JSON(result)
- reply, err := d.DataFansArea(c, arg)
- ctx.Convey("Then err should be nil.reply should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(reply, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestUpDataFansType(t *testing.T) {
- convey.Convey("DataFansType", t, func(ctx convey.C) {
- var (
- c = context.Background()
- arg = &model.McnCommonReq{SignID: 1}
- )
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- defer gock.OffAll()
- result := `{
- "message":"",
- "code":0,
- "data":{
- "result":[
- {
- "type_id":0,
- "user":0,
- "type_name":""
- }
- ]
- }
- }`
- httpMock("GET", d.dataFansTypeURL).Reply(200).JSON(result)
- reply, err := d.DataFansType(c, arg)
- ctx.Convey("Then err should be nil.reply should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(reply, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestUpDataFansTag(t *testing.T) {
- convey.Convey("DataFansTag", t, func(ctx convey.C) {
- var (
- c = context.Background()
- arg = &model.McnCommonReq{SignID: 1}
- )
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- defer gock.OffAll()
- result := `{
- "message":"",
- "code":0,
- "data":{
- "result":[
- {
- "tag_id":0,
- "user":0,
- "tag_name":""
- }
- ]
- }
- }`
- httpMock("GET", d.dataFansTagURL).Reply(200).JSON(result)
- reply, err := d.DataFansTag(c, arg)
- ctx.Convey("Then err should be nil.reply should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(reply, convey.ShouldNotBeNil)
- })
- })
- })
- }
|