123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- package dao
- import (
- "context"
- "go-common/app/service/main/tv/internal/model"
- "testing"
- "github.com/smartystreets/goconvey/convey"
- )
- func TestDaoCacheUserInfoByMid(t *testing.T) {
- convey.Convey("CacheUserInfoByMid", t, func(ctx convey.C) {
- var (
- c = context.Background()
- id = int64(27515308)
- )
- d.AddCacheUserInfoByMid(c, id, &model.UserInfo{})
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- res, err := d.CacheUserInfoByMid(c, id)
- ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(res, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestDaoAddCacheUserInfoByMid(t *testing.T) {
- convey.Convey("AddCacheUserInfoByMid", t, func(ctx convey.C) {
- var (
- c = context.Background()
- id = int64(27515308)
- val = &model.UserInfo{}
- )
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- err := d.AddCacheUserInfoByMid(c, id, val)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestDaoDelCacheUserInfoByMid(t *testing.T) {
- convey.Convey("DelCacheUserInfoByMid", t, func(ctx convey.C) {
- var (
- c = context.Background()
- id = int64(27515308)
- )
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- err := d.DelCacheUserInfoByMid(c, id)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestDaoCachePayParamByToken(t *testing.T) {
- convey.Convey("CachePayParamByToken", t, func(ctx convey.C) {
- var (
- c = context.Background()
- id = "TOKEN:34567345678"
- )
- d.AddCachePayParam(context.TODO(), id, &model.PayParam{})
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- res, err := d.CachePayParamByToken(c, id)
- ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(res, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestDaoCachePayParamsByTokens(t *testing.T) {
- convey.Convey("CachePayParamsByTokens", t, func(ctx convey.C) {
- var (
- c = context.Background()
- ids = []string{"TOKEN:34567345678"}
- )
- d.AddCachePayParam(context.TODO(), ids[0], &model.PayParam{})
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- res, err := d.CachePayParamsByTokens(c, ids)
- ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(res, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestDaoAddCachePayParam(t *testing.T) {
- convey.Convey("AddCachePayParam", t, func(ctx convey.C) {
- var (
- c = context.Background()
- id = "TOKEN:34567345678"
- val = &model.PayParam{}
- )
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- err := d.AddCachePayParam(c, id, val)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestDaoUpdateCachePayParam(t *testing.T) {
- convey.Convey("UpdateCachePayParam", t, func(ctx convey.C) {
- var (
- c = context.Background()
- id = "TOKEN:34567345678"
- val = &model.PayParam{}
- )
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- err := d.UpdateCachePayParam(c, id, val)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
|