Simple and Powerful ORM for Go, support mysql,postgres,tidb,sqlite3,mssql,oracle https://xorm.io
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
704B

  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. }