gorush/storage/buntdb/buntdb_test.go

45 lines
891 B
Go
Raw Normal View History

package buntdb
import (
c "github.com/appleboy/gorush/config"
"github.com/stretchr/testify/assert"
"testing"
)
func TestBuntDBEngine(t *testing.T) {
var val int64
config := c.BuildDefaultPushConf()
buntDB := New(config)
buntDB.Init()
buntDB.Reset()
buntDB.AddTotalCount(10)
val = buntDB.GetTotalCount()
assert.Equal(t, int64(10), val)
buntDB.AddTotalCount(10)
val = buntDB.GetTotalCount()
assert.Equal(t, int64(20), val)
buntDB.AddIosSuccess(20)
val = buntDB.GetIosSuccess()
assert.Equal(t, int64(20), val)
buntDB.AddIosError(30)
val = buntDB.GetIosError()
assert.Equal(t, int64(30), val)
buntDB.AddAndroidSuccess(40)
val = buntDB.GetAndroidSuccess()
assert.Equal(t, int64(40), val)
buntDB.AddAndroidError(50)
val = buntDB.GetAndroidError()
assert.Equal(t, int64(50), val)
buntDB.Reset()
val = buntDB.GetAndroidError()
assert.Equal(t, int64(0), val)
}