Add memory reset func.

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu 2016-08-03 15:02:13 +08:00
parent 1326aae547
commit 45fbb4933c
2 changed files with 10 additions and 1 deletions

View File

@ -42,6 +42,11 @@ func (s *Storage) Init() error {
// Reset Client storage. // Reset Client storage.
func (s *Storage) Reset() { func (s *Storage) Reset() {
atomic.StoreInt64(&s.stat.TotalCount, 0)
atomic.StoreInt64(&s.stat.Ios.PushSuccess, 0)
atomic.StoreInt64(&s.stat.Ios.PushError, 0)
atomic.StoreInt64(&s.stat.Android.PushSuccess, 0)
atomic.StoreInt64(&s.stat.Android.PushError, 0)
} }
// AddTotalCount record push notification count. // AddTotalCount record push notification count.

View File

@ -16,6 +16,10 @@ func TestMemoryEngine(t *testing.T) {
val = memory.GetTotalCount() val = memory.GetTotalCount()
assert.Equal(t, int64(1), val) assert.Equal(t, int64(1), val)
memory.AddTotalCount(100)
val = memory.GetTotalCount()
assert.Equal(t, int64(101), val)
memory.AddIosSuccess(2) memory.AddIosSuccess(2)
val = memory.GetIosSuccess() val = memory.GetIosSuccess()
assert.Equal(t, int64(2), val) assert.Equal(t, int64(2), val)
@ -34,6 +38,6 @@ func TestMemoryEngine(t *testing.T) {
// test reset db // test reset db
memory.Reset() memory.Reset()
val = memory.GetAndroidError() val = memory.GetTotalCount()
assert.Equal(t, int64(0), val) assert.Equal(t, int64(0), val)
} }