Add memory reset func.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
parent
1326aae547
commit
45fbb4933c
|
@ -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.
|
||||||
|
|
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue