123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- package dao
- import (
- "context"
- "testing"
- mml "go-common/app/service/main/member/model"
- bml "go-common/app/service/main/member/model/block"
- "go-common/library/ecode"
- "github.com/smartystreets/goconvey/convey"
- )
- func TestDaoRawInfo(t *testing.T) {
- var (
- c = context.TODO()
- mid = int64(110016481)
- )
- convey.Convey("Get base-info from member-rpc", t, func(ctx convey.C) {
- res, err := d.RawInfo(c, mid)
- ctx.Convey("Then err should be nil and res should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(res, convey.ShouldNotBeNil)
- })
- })
- }
- func TestDaoRawInfos(t *testing.T) {
- var (
- c = context.TODO()
- mids = []int64{110016811, 110017441}
- )
- convey.Convey("Batch get base-info from member-rpc", t, func(ctx convey.C) {
- res, err := d.RawInfos(c, mids)
- ctx.Convey("Then err should be nil and res should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(res, convey.ShouldNotBeNil)
- })
- })
- }
- func TestDaoRawCard(t *testing.T) {
- var (
- c = context.TODO()
- mid = int64(110018101)
- )
- convey.Convey("Get card-info from member-rpc", t, func(ctx convey.C) {
- res, err := d.RawCard(c, mid)
- ctx.Convey("Then err should be nil and res should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(res, convey.ShouldNotBeNil)
- })
- })
- }
- func TestDaoRawCards(t *testing.T) {
- var (
- c = context.TODO()
- mids = []int64{110019691, 110019241}
- )
- convey.Convey("Batch get card-info from member-rpc", t, func(ctx convey.C) {
- res, err := d.RawCards(c, mids)
- ctx.Convey("Then err should be nil and res should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(res, convey.ShouldNotBeNil)
- })
- })
- }
- func TestDaoRawProfile(t *testing.T) {
- var (
- c = context.TODO()
- mid = int64(110019691)
- )
- convey.Convey("Get profile-info from member-rpc", t, func(ctx convey.C) {
- res, err := d.RawProfile(c, mid)
- if err == ecode.Degrade {
- err = nil
- }
- ctx.Convey("Then err should be nil and res should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(res, convey.ShouldNotBeNil)
- })
- })
- }
- func TestDaoblockStatusToSilence(t *testing.T) {
- var (
- status bml.BlockStatus
- )
- convey.Convey("Check whether member in block status ", t, func(ctx convey.C) {
- p1 := blockStatusToSilence(status)
- ctx.Convey("Then p1 should be 0 or 1.", func(ctx convey.C) {
- ctx.So(p1, convey.ShouldBeIn, []int32{0, 1})
- })
- })
- }
- func TestDaobindEmailStatus(t *testing.T) {
- var (
- email = "zxfd43622@qq.com"
- spacesta = int8(0)
- )
- convey.Convey("Get member bind-email status", t, func(ctx convey.C) {
- p1 := bindEmailStatus(email, spacesta)
- ctx.Convey("Then p1 should be 0 or 1.", func(ctx convey.C) {
- ctx.So(p1, convey.ShouldBeIn, []int32{0, 1})
- })
- })
- }
- func TestDaobindPhoneStatus(t *testing.T) {
- var (
- phone = "13849920122"
- )
- convey.Convey("Get member bind-phone status", t, func(ctx convey.C) {
- p1 := bindPhoneStatus(phone)
- ctx.Convey("Then p1 should be 0 or 1.", func(ctx convey.C) {
- ctx.So(p1, convey.ShouldBeIn, []int32{0, 1})
- })
- })
- }
- func TestDaoparseMoral(t *testing.T) {
- var (
- moral = &mml.Moral{
- Mid: 3441,
- Moral: 7100,
- Added: 100,
- Deducted: 0,
- }
- )
- convey.Convey("Parse moral value", t, func(ctx convey.C) {
- p1 := parseMoral(moral)
- ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
- ctx.So(p1, convey.ShouldNotBeNil)
- })
- })
- }
- func TestDaoidentificationStatus(t *testing.T) {
- var (
- realNameStatus = mml.RealnameStatusTrue
- )
- convey.Convey("Get identification status", t, func(ctx convey.C) {
- p1 := identificationStatus(realNameStatus)
- ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
- ctx.So(p1, convey.ShouldEqual, 1)
- })
- })
- }
- func TestDaoboolToInt32(t *testing.T) {
- var (
- b = true
- )
- convey.Convey("Convert true to int", t, func(ctx convey.C) {
- p1 := boolToInt32(b)
- ctx.Convey("Then p1 should be 1.", func(ctx convey.C) {
- ctx.So(p1, convey.ShouldEqual, 1)
- })
- })
- }
|