123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- package archive
- import (
- "context"
- "testing"
- . "github.com/smartystreets/goconvey/convey"
- "go-common/app/service/main/videoup/model/archive"
- "math/rand"
- "time"
- )
- func TestDao_TxAddVideo(t *testing.T) {
- var (
- c = context.Background()
- tx, _ = d.BeginTran(c)
- v = &archive.Video{
- ID: 123,
- Aid: 2333,
- Title: "UT测试",
- }
- )
- rand.Seed(time.Now().Unix())
- v.ID = int64(rand.Intn(999999999) + 1000000000)
- v.Aid = int64(rand.Intn(999999999) + 1000000000)
- Convey("TxAddVideo", t, func(ctx C) {
- _, err := d.TxAddVideo(tx, v)
- if err != nil {
- tx.Rollback()
- } else {
- tx.Commit()
- }
- So(err, ShouldBeNil)
- })
- }
- func TestDao_TxUpVideo(t *testing.T) {
- var (
- c = context.Background()
- tx, _ = d.BeginTran(c)
- v = &archive.Video{
- ID: 123,
- Aid: 2333,
- Title: "UT测试",
- }
- )
- Convey("TxUpVideo", t, func(ctx C) {
- _, err := d.TxUpVideo(tx, v)
- if err != nil {
- tx.Rollback()
- } else {
- tx.Commit()
- }
- So(err, ShouldBeNil)
- })
- }
- func TestDao_TxUpVideoStatus(t *testing.T) {
- var (
- c = context.Background()
- tx, _ = d.BeginTran(c)
- )
- Convey("TxUpVideoStatus", t, func(ctx C) {
- _, err := d.TxUpVideoStatus(tx, 2333, "sadasdadsds", 0)
- if err != nil {
- tx.Rollback()
- } else {
- tx.Commit()
- }
- So(err, ShouldBeNil)
- })
- }
- func TestDao_TxUpVideoXcode(t *testing.T) {
- var (
- c = context.Background()
- tx, _ = d.BeginTran(c)
- )
- Convey("TxUpVideoXcode", t, func(ctx C) {
- _, err := d.TxUpVideoXcode(tx, 2333, "sadasdadsds", 0)
- if err != nil {
- tx.Rollback()
- } else {
- tx.Commit()
- }
- So(err, ShouldBeNil)
- })
- }
- func TestDao_TxUpVideoAttr(t *testing.T) {
- var (
- c = context.Background()
- tx, _ = d.BeginTran(c)
- )
- Convey("TxUpVideoAttr", t, func(ctx C) {
- _, err := d.TxUpVideoAttr(tx, 2333, "sadasdadsds", 0)
- if err != nil {
- tx.Rollback()
- } else {
- tx.Commit()
- }
- So(err, ShouldBeNil)
- })
- }
- func TestDao_TxUpVideoCid(t *testing.T) {
- var (
- c = context.Background()
- tx, _ = d.BeginTran(c)
- )
- Convey("TxUpVideoCid", t, func(ctx C) {
- _, err := d.TxUpVideoCid(tx, 2333, "sadasdadsds", 1213)
- if err != nil {
- tx.Rollback()
- } else {
- tx.Commit()
- }
- So(err, ShouldBeNil)
- })
- }
- func TestDao_TxAddAudit(t *testing.T) {
- rand.Seed(time.Now().Unix())
- vid := int64(rand.Intn(999999) + 1000000000)
- var (
- c = context.Background()
- tx, _ = d.BeginTran(c)
- vs = []*archive.Video{{
- ID: vid,
- Aid: 2333,
- Title: "UT测试",
- }}
- )
- Convey("TxAddAudit", t, func(ctx C) {
- _, err := d.TxAddAudit(tx, vs)
- if err != nil {
- tx.Rollback()
- } else {
- tx.Commit()
- }
- So(err, ShouldBeNil)
- })
- }
|