Add storage module test + update Bessere Tests

This commit is contained in:
JeremyStar™ 2024-04-06 13:13:12 +02:00
parent bff4e48d3b
commit 527d4d19ab
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D
2 changed files with 68 additions and 1 deletions

@ -1 +1 @@
Subproject commit a58bfb23dc389ec60e3f45fbb0433e107755c4ea Subproject commit 7b9c84b805e286b7989534bcba6e5b45badc0e52

67
tests/unit/storage.gd Normal file
View 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)