2016-05-02 06:52:38 +00:00
|
|
|
package boltdb
|
|
|
|
|
|
|
|
import (
|
2016-05-03 01:56:59 +00:00
|
|
|
c "github.com/appleboy/gorush/config"
|
2016-05-02 06:52:38 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestRedisEngine(t *testing.T) {
|
|
|
|
var val int64
|
|
|
|
|
2016-05-02 12:22:37 +00:00
|
|
|
config := c.BuildDefaultPushConf()
|
2016-05-02 06:52:38 +00:00
|
|
|
|
2016-05-02 12:22:37 +00:00
|
|
|
boltDB := New(config)
|
|
|
|
boltDB.Init()
|
|
|
|
boltDB.Reset()
|
2016-05-02 06:52:38 +00:00
|
|
|
|
2016-05-02 12:22:37 +00:00
|
|
|
boltDB.AddTotalCount(10)
|
|
|
|
val = boltDB.GetTotalCount()
|
2016-05-02 06:52:38 +00:00
|
|
|
assert.Equal(t, int64(10), val)
|
2016-05-02 12:22:37 +00:00
|
|
|
boltDB.AddTotalCount(10)
|
|
|
|
val = boltDB.GetTotalCount()
|
2016-05-02 06:52:38 +00:00
|
|
|
assert.Equal(t, int64(20), val)
|
|
|
|
|
2016-05-02 12:22:37 +00:00
|
|
|
boltDB.AddIosSuccess(20)
|
|
|
|
val = boltDB.GetIosSuccess()
|
2016-05-02 06:52:38 +00:00
|
|
|
assert.Equal(t, int64(20), val)
|
|
|
|
|
2016-05-02 12:22:37 +00:00
|
|
|
boltDB.AddIosError(30)
|
|
|
|
val = boltDB.GetIosError()
|
2016-05-02 06:52:38 +00:00
|
|
|
assert.Equal(t, int64(30), val)
|
|
|
|
|
2016-05-02 12:22:37 +00:00
|
|
|
boltDB.AddAndroidSuccess(40)
|
|
|
|
val = boltDB.GetAndroidSuccess()
|
2016-05-02 06:52:38 +00:00
|
|
|
assert.Equal(t, int64(40), val)
|
|
|
|
|
2016-05-02 12:22:37 +00:00
|
|
|
boltDB.AddAndroidError(50)
|
|
|
|
val = boltDB.GetAndroidError()
|
2016-05-02 06:52:38 +00:00
|
|
|
assert.Equal(t, int64(50), val)
|
|
|
|
}
|