memorygraphstorage_test.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * EliasDB
  3. *
  4. * Copyright 2016 Matthias Ladkau. All rights reserved.
  5. *
  6. * This Source Code Form is subject to the terms of the Mozilla Public
  7. * License, v. 2.0. If a copy of the MPL was not distributed with this
  8. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  9. */
  10. package graphstorage
  11. import "testing"
  12. func TestMemoryGraphStorage(t *testing.T) {
  13. mstore := NewMemoryGraphStorage("mytest")
  14. // Test nop functions
  15. mstore.FlushAll()
  16. mstore.RollbackMain()
  17. mstore.FlushMain()
  18. mstore.Close()
  19. if mstore.Name() != "mytest" {
  20. t.Error("Unexpected name:", mstore.Name())
  21. }
  22. mstore.MainDB()["test1"] = "testvalue1"
  23. if mstore.MainDB()["test1"] != "testvalue1" {
  24. t.Error("Unexpected name db value")
  25. return
  26. }
  27. if res := mstore.StorageManager("123", false); res != nil {
  28. t.Error("Unexpected result", res)
  29. return
  30. }
  31. res := mstore.StorageManager("123", true)
  32. if res == nil {
  33. t.Error("Unexpected result", res)
  34. return
  35. }
  36. loc, _ := res.Insert("test")
  37. sm2 := mstore.StorageManager("123", false)
  38. if res2, _ := sm2.FetchCached(loc); res2.(string) != "test" {
  39. t.Error("Unexpected result", res2)
  40. return
  41. }
  42. }