123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- package archive
- import (
- "context"
- "testing"
- "time"
- . "github.com/smartystreets/goconvey/convey"
- "go-common/app/service/main/videoup/model/archive"
- )
- func TestDao_TxAddArcHistory(t *testing.T) {
- var (
- c = context.Background()
- tx, _ = d.BeginTran(c)
- )
- Convey("TxAddArcHistory", t, func(ctx C) {
- _, err := d.TxAddArcHistory(tx, 23333, 123, "ssss", "content", "", "")
- if err != nil {
- tx.Rollback()
- } else {
- tx.Commit()
- }
- So(err, ShouldBeNil)
- })
- }
- func TestDao_TxAddVideoHistory(t *testing.T) {
- var (
- c = context.Background()
- tx, _ = d.BeginTran(c)
- v = &archive.Video{
- Aid: 23333,
- Cid: 12121,
- Title: "sssss",
- }
- )
- Convey("TxAddVideoHistory", t, func(ctx C) {
- _, err := d.TxAddVideoHistory(tx, 23333, v)
- if err != nil {
- tx.Rollback()
- } else {
- tx.Commit()
- }
- So(err, ShouldBeNil)
- })
- }
- func TestDao_TxUpVideoHistory(t *testing.T) {
- var (
- c = context.Background()
- tx, _ = d.BeginTran(c)
- )
- Convey("TxUpVideoHistory", t, func(ctx C) {
- _, err := d.TxUpVideoHistory(tx, 23333, 1212, "")
- if err != nil {
- tx.Rollback()
- } else {
- tx.Commit()
- }
- So(err, ShouldBeNil)
- })
- }
- func TestDao_TxAddVideoHistorys(t *testing.T) {
- var (
- c = context.Background()
- tx, _ = d.BeginTran(c)
- vs = []*archive.Video{{
- Aid: 23333,
- Cid: 12121,
- Title: "sssss",
- }}
- )
- Convey("TxAddVideoHistorys", t, func(ctx C) {
- err := d.TxAddVideoHistorys(tx, 23333, vs)
- if err != nil {
- tx.Rollback()
- } else {
- tx.Commit()
- }
- So(err, ShouldBeNil)
- })
- }
- func TestArchiveArcHistory(t *testing.T) {
- var (
- c = context.Background()
- hid = int64(23333)
- )
- Convey("ArcHistory", t, func(ctx C) {
- _, err := d.ArcHistory(c, hid)
- ctx.Convey("Then err should be nil.ah should not be nil.", func(ctx C) {
- ctx.So(err, ShouldBeNil)
- })
- })
- }
- func TestArchiveArcHistorys(t *testing.T) {
- var (
- c = context.Background()
- aid = int64(23333)
- stime = time.Now()
- )
- Convey("ArcHistorys", t, func(ctx C) {
- _, err := d.ArcHistorys(c, aid, stime)
- ctx.Convey("Then err should be nil.ahs should not be nil.", func(ctx C) {
- ctx.So(err, ShouldBeNil)
- })
- })
- }
- func TestArchiveVideoHistory(t *testing.T) {
- var (
- c = context.Background()
- hid = int64(23333)
- )
- Convey("VideoHistory", t, func(ctx C) {
- _, err := d.VideoHistory(c, hid)
- ctx.Convey("Then err should be nil.vhs should not be nil.", func(ctx C) {
- ctx.So(err, ShouldBeNil)
- })
- })
- }
|