bbgo_origin/pkg/service/memory_test.go

34 lines
553 B
Go
Raw Permalink Normal View History

package service
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestMemoryService(t *testing.T) {
t.Run("load_empty", func(t *testing.T) {
service := NewMemoryService()
store := service.NewStore("test")
j := 0
err := store.Load(&j)
assert.Error(t, err)
})
t.Run("save_and_load", func(t *testing.T) {
service := NewMemoryService()
store := service.NewStore("test")
i := 3
2022-05-05 09:56:41 +00:00
err := store.Save(i)
assert.NoError(t, err)
var j = 0
err = store.Load(&j)
assert.NoError(t, err)
assert.Equal(t, i, j)
})
}