feat(client): FallbackLibrary + authored narrator fallback (§13)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
33
client/tests/unit/test_fallback_library.gd
Normal file
33
client/tests/unit/test_fallback_library.gd
Normal file
@@ -0,0 +1,33 @@
|
||||
extends "res://addons/gut/test.gd"
|
||||
|
||||
const FallbackLibrary = preload("res://scripts/net/fallback_library.gd")
|
||||
|
||||
|
||||
func test_loads_authored_line_from_default_file():
|
||||
var lib = FallbackLibrary.new()
|
||||
# The authored line is distinct from LAST_RESORT, so a match proves the file was read.
|
||||
assert_ne(lib.narrator_line(), FallbackLibrary.LAST_RESORT)
|
||||
assert_true(lib.narrator_line().length() > 0)
|
||||
|
||||
|
||||
func test_missing_file_uses_last_resort():
|
||||
var lib = FallbackLibrary.new("res://content/fallback/does_not_exist.json")
|
||||
assert_eq(lib.narrator_line(), FallbackLibrary.LAST_RESORT)
|
||||
|
||||
|
||||
func test_malformed_file_uses_last_resort():
|
||||
var path := "user://bad_fallback.json"
|
||||
var f := FileAccess.open(path, FileAccess.WRITE)
|
||||
f.store_string("{ this is not valid json")
|
||||
f.close()
|
||||
var lib = FallbackLibrary.new(path)
|
||||
assert_eq(lib.narrator_line(), FallbackLibrary.LAST_RESORT)
|
||||
|
||||
|
||||
func test_empty_list_uses_last_resort():
|
||||
var path := "user://empty_fallback.json"
|
||||
var f := FileAccess.open(path, FileAccess.WRITE)
|
||||
f.store_string('{"narrator": []}')
|
||||
f.close()
|
||||
var lib = FallbackLibrary.new(path)
|
||||
assert_eq(lib.narrator_line(), FallbackLibrary.LAST_RESORT)
|
||||
Reference in New Issue
Block a user