Add storage module test + update Bessere Tests
This commit is contained in:
parent
18e66e9af1
commit
baf98e0329
2 changed files with 68 additions and 1 deletions
2
dist/submodules/besseretests
vendored
2
dist/submodules/besseretests
vendored
|
@ -1 +1 @@
|
|||
Subproject commit a58bfb23dc389ec60e3f45fbb0433e107755c4ea
|
||||
Subproject commit 7b9c84b805e286b7989534bcba6e5b45badc0e52
|
67
tests/unit/storage.gd
Normal file
67
tests/unit/storage.gd
Normal file
|
@ -0,0 +1,67 @@
|
|||
extends 'res://tests/unitbase.gd'
|
||||
|
||||
var path: String = "user://testconfig.json"
|
||||
|
||||
func before_each() -> void:
|
||||
remove_storagefile()
|
||||
super()
|
||||
|
||||
func test_basic() -> void:
|
||||
await load_framework()
|
||||
|
||||
if !core.storage.open_storage(path):
|
||||
rerror("open_storage(location='" + path + "') returned 'false'")
|
||||
return
|
||||
|
||||
if !core.storage.set_key("is_test", "yes it is"):
|
||||
rerror("set_key(key='is_test' value='yes it is') returned 'false'")
|
||||
return
|
||||
if core.storage.get_key("is_test") != "yes it is":
|
||||
rerror("get_key(key='is_test') did not return 'yes it is' (got '" + str(core.storage.get_key("is_test")) + "')")
|
||||
return
|
||||
if !core.storage.del_key("is_test"):
|
||||
rerror("del_key(key='is_test') did not return 'true'")
|
||||
return
|
||||
|
||||
if !core.storage.close_storage():
|
||||
rerror("close_storage() did not return 'true'")
|
||||
return
|
||||
|
||||
rok()
|
||||
|
||||
func test_advanced() -> void:
|
||||
await load_framework()
|
||||
|
||||
if !core.storage.open_storage(path):
|
||||
rerror("open_storage(location='" + path + "') returned 'false'")
|
||||
return
|
||||
|
||||
if !core.storage.set_key("is_test", "yes it is", false, false):
|
||||
rerror("set_key(key='is_test' value='yes it is') returned 'false'")
|
||||
return
|
||||
if core.storage.get_key("is_test") != "yes it is":
|
||||
rerror("get_key(key='is_test') did not return 'yes it is' (got '" + str(core.storage.get_key("is_test")) + "')")
|
||||
return
|
||||
|
||||
if !core.storage.save_storage():
|
||||
rerror("save_storage() did not return 'true'")
|
||||
return
|
||||
|
||||
if core.storage.get_dict() != { "is_test": "yes it is" }:
|
||||
rerror("get_dict() did not return '{ \"is_test\": \"yes it is\" }' (got '" + str(core.storage.get_dict()) + "')")
|
||||
return
|
||||
|
||||
if !core.storage.nuke_storage():
|
||||
rerror("nuke_storage() did not return 'true'")
|
||||
return
|
||||
|
||||
if !core.storage.close_storage():
|
||||
rerror("close_storage() did not return 'true'")
|
||||
return
|
||||
|
||||
rok()
|
||||
|
||||
func remove_storagefile() -> void:
|
||||
if FileAccess.file_exists(path):
|
||||
lverb("Removing '" + path + "'")
|
||||
DirAccess.remove_absolute(path)
|
Loading…
Reference in a new issue