From 45fbb4933cb924d9954bf653b5e1f764f8e3c258 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Wed, 3 Aug 2016 15:02:13 +0800 Subject: [PATCH] Add memory reset func. Signed-off-by: Bo-Yi Wu --- storage/memory/memory.go | 5 +++++ storage/memory/memory_test.go | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/storage/memory/memory.go b/storage/memory/memory.go index d8b689e..af8ad67 100644 --- a/storage/memory/memory.go +++ b/storage/memory/memory.go @@ -42,6 +42,11 @@ func (s *Storage) Init() error { // Reset Client storage. 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. diff --git a/storage/memory/memory_test.go b/storage/memory/memory_test.go index cf7800b..4d428a9 100644 --- a/storage/memory/memory_test.go +++ b/storage/memory/memory_test.go @@ -16,6 +16,10 @@ func TestMemoryEngine(t *testing.T) { val = memory.GetTotalCount() assert.Equal(t, int64(1), val) + memory.AddTotalCount(100) + val = memory.GetTotalCount() + assert.Equal(t, int64(101), val) + memory.AddIosSuccess(2) val = memory.GetIosSuccess() assert.Equal(t, int64(2), val) @@ -34,6 +38,6 @@ func TestMemoryEngine(t *testing.T) { // test reset db memory.Reset() - val = memory.GetAndroidError() + val = memory.GetTotalCount() assert.Equal(t, int64(0), val) }