diff tests/test_storage.nim @ 1499:1f58458b7ef7 default tip

did: fix a few issues with tests
author sam <sam@basx.dev>
date Tue, 14 Oct 2025 00:27:28 +0700
parents 63364723d460
children
line wrap: on
line diff
--- a/tests/test_storage.nim	Thu Sep 25 23:53:41 2025 +0700
+++ b/tests/test_storage.nim	Tue Oct 14 00:27:28 2025 +0700
@@ -1,4 +1,5 @@
 import std/strformat
+import std/sequtils
 
 import ../semicongine
 import ../semicongine/storage
@@ -34,8 +35,10 @@
 
   const obj1 = Obj1(value: 42, id: ID(1))
   "testWorld".storeWorld(obj1)
-  assert listWorlds() == @["testWorld"]
-  assert loadWorld[Obj1]("testWorld") == obj1
+  assert listWorlds()[0][1] == "testWorld"
+  var myWorld: Obj1
+  loadWorld[Obj1]("testWorld", myWorld)
+  assert myWorld == obj1
 
   const obj2 = Obj2(
     a: "Hello world",
@@ -47,16 +50,20 @@
     e: true,
   )
   "testWorld".storeWorld(obj2)
-  assert listWorlds() == @["testWorld"]
-  assert loadWorld[Obj2]("testWorld") == obj2
+  assert listWorlds()[0][1] == "testWorld"
+  var otherWorld: Obj2
+  loadWorld[Obj2]("testWorld", otherWorld)
+  assert otherWorld == obj2
 
   "earth".storeWorld(obj2)
-  assert "earth" in listWorlds()
-  assert "testWorld" in listWorlds()
-  assert loadWorld[Obj2]("earth") == obj2
+  assert "earth" in listWorlds().mapIt(it[1])
+  assert "testWorld" in listWorlds().mapIt(it[1])
+  var moreWorld: Obj2
+  loadWorld[Obj2]("earth", moreWorld)
+  assert moreWorld == obj2
 
   "earth".purgeWorld()
-  assert listWorlds() == @["testWorld"]
+  assert listWorlds()[0][1] == "testWorld"
 
   "testWorld".purgeWorld()
   assert listWorlds().len == 0