cache_memory_store_test.go 704 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright 2015 The Xorm Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package xorm
  5. import (
  6. "testing"
  7. "github.com/stretchr/testify/assert"
  8. )
  9. func TestMemoryStore(t *testing.T) {
  10. store := NewMemoryStore()
  11. var kvs = map[string]interface{}{
  12. "a": "b",
  13. }
  14. for k, v := range kvs {
  15. assert.NoError(t, store.Put(k, v))
  16. }
  17. for k, v := range kvs {
  18. val, err := store.Get(k)
  19. assert.NoError(t, err)
  20. assert.EqualValues(t, v, val)
  21. }
  22. for k, _ := range kvs {
  23. err := store.Del(k)
  24. assert.NoError(t, err)
  25. }
  26. for k, _ := range kvs {
  27. _, err := store.Get(k)
  28. assert.EqualValues(t, ErrNotExist, err)
  29. }
  30. }