2016-05-02 03:04:19 +00:00
|
|
|
package memory
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2017-01-19 09:08:12 +00:00
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2016-05-02 03:04:19 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestMemoryEngine(t *testing.T) {
|
|
|
|
var val int64
|
|
|
|
|
2016-05-02 09:03:08 +00:00
|
|
|
memory := New()
|
2016-05-02 03:04:19 +00:00
|
|
|
|
2016-06-30 05:47:10 +00:00
|
|
|
assert.Nil(t, memory.Init())
|
|
|
|
|
2016-05-02 09:03:08 +00:00
|
|
|
memory.AddTotalCount(1)
|
|
|
|
val = memory.GetTotalCount()
|
2016-05-02 03:04:19 +00:00
|
|
|
assert.Equal(t, int64(1), val)
|
|
|
|
|
2016-08-03 07:02:13 +00:00
|
|
|
memory.AddTotalCount(100)
|
|
|
|
val = memory.GetTotalCount()
|
|
|
|
assert.Equal(t, int64(101), val)
|
|
|
|
|
2016-05-02 09:03:08 +00:00
|
|
|
memory.AddIosSuccess(2)
|
|
|
|
val = memory.GetIosSuccess()
|
2016-05-02 03:04:19 +00:00
|
|
|
assert.Equal(t, int64(2), val)
|
|
|
|
|
2016-05-02 09:03:08 +00:00
|
|
|
memory.AddIosError(3)
|
|
|
|
val = memory.GetIosError()
|
2016-05-02 03:04:19 +00:00
|
|
|
assert.Equal(t, int64(3), val)
|
|
|
|
|
2016-05-02 09:03:08 +00:00
|
|
|
memory.AddAndroidSuccess(4)
|
|
|
|
val = memory.GetAndroidSuccess()
|
2016-05-02 03:04:19 +00:00
|
|
|
assert.Equal(t, int64(4), val)
|
|
|
|
|
2016-05-02 09:03:08 +00:00
|
|
|
memory.AddAndroidError(5)
|
|
|
|
val = memory.GetAndroidError()
|
2016-05-02 03:04:19 +00:00
|
|
|
assert.Equal(t, int64(5), val)
|
2016-08-03 06:30:21 +00:00
|
|
|
|
|
|
|
// test reset db
|
|
|
|
memory.Reset()
|
2016-08-03 07:02:13 +00:00
|
|
|
val = memory.GetTotalCount()
|
2016-08-03 06:30:21 +00:00
|
|
|
assert.Equal(t, int64(0), val)
|
2016-05-02 03:04:19 +00:00
|
|
|
}
|