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