123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- package dao
- import (
- "context"
- "testing"
- "go-common/app/service/main/reply-feed/model"
- "github.com/smartystreets/goconvey/convey"
- )
- func TestDaoSlotsMapping(t *testing.T) {
- convey.Convey("SlotsMapping", t, func(ctx convey.C) {
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- slotsMap, err := d.SlotsMapping(context.Background())
- ctx.Convey("Then err should be nil.slotsMap should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(slotsMap, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestDaoSlotsStatManager(t *testing.T) {
- convey.Convey("SlotsStatManager", t, func(ctx convey.C) {
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- s, err := d.SlotsStatManager(context.Background())
- ctx.Convey("Then err should be nil.s should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(s, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestDaoIdleSlot(t *testing.T) {
- convey.Convey("IdleSlot", t, func(ctx convey.C) {
- var (
- count = int(0)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- slots, err := d.IdleSlots(context.Background(), count)
- ctx.Convey("Then err should be nil.slots should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(slots, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestDaoCountIdleSlot(t *testing.T) {
- convey.Convey("CountIdleSlot", t, func(ctx convey.C) {
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- count, err := d.CountIdleSlot(context.Background())
- ctx.Convey("Then err should be nil. count should greater than 0.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(count, convey.ShouldBeGreaterThan, 0)
- })
- })
- })
- }
- func TestDaoModifyState(t *testing.T) {
- convey.Convey("ModifyState", t, func(ctx convey.C) {
- var (
- name = ""
- state = int(0)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- err := d.ModifyState(context.Background(), name, state)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestDaoUpdateSlotsStat(t *testing.T) {
- convey.Convey("UpdateSlotsStat", t, func(ctx convey.C) {
- var (
- name = ""
- algorithm = ""
- weight = ""
- slots = []int64{-1}
- state = int(0)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- err := d.UpdateSlotsStat(context.Background(), name, algorithm, weight, slots, state)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestSlotsStatByName(t *testing.T) {
- convey.Convey("SlotsStatByName", t, func(ctx convey.C) {
- var (
- name = ""
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- slots, algorithm, weight, err := d.SlotsStatByName(context.Background(), name)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(slots, convey.ShouldBeNil)
- ctx.So(algorithm, convey.ShouldEqual, "")
- ctx.So(weight, convey.ShouldEqual, "")
- })
- })
- })
- }
- func TestDaoUpdateWeight(t *testing.T) {
- convey.Convey("UpdateWeight", t, func(ctx convey.C) {
- var (
- name = ""
- weight = interface{}(0)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- err := d.UpdateWeight(context.Background(), name, weight)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestDaoUpsertStatistics(t *testing.T) {
- convey.Convey("UpsertStatistics", t, func(ctx convey.C) {
- var (
- name = ""
- date = int(0)
- hour = int(0)
- s = &model.StatisticsStat{}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- err := d.UpsertStatistics(context.Background(), name, date, hour, s)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestDaoStatisticsByDate(t *testing.T) {
- convey.Convey("StatisticsByDate", t, func(ctx convey.C) {
- var (
- begin = int64(0)
- end = int64(0)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- stats, err := d.StatisticsByDate(context.Background(), begin, end)
- ctx.Convey("Then err should be nil.stats should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(stats, convey.ShouldNotBeNil)
- })
- })
- })
- }
|