Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HuHRPE7VfppUJEaoGBEUqZ
69 lines
1.7 KiB
GDScript
69 lines
1.7 KiB
GDScript
extends "res://addons/gut/test.gd"
|
|
|
|
const ContentDB = preload("res://scripts/content/content_db.gd")
|
|
|
|
var db
|
|
|
|
|
|
func before_each():
|
|
db = ContentDB.new()
|
|
db.load_from(ContentDB.default_content_root())
|
|
|
|
|
|
func _deserter() -> Dictionary:
|
|
return ContentDB.load_json(ContentDB.origin_path("deserter"))
|
|
|
|
|
|
func test_loads_world_ids():
|
|
assert_true(db.has_location("greywater_docks"))
|
|
assert_true(db.has_quest("find_the_ledger"))
|
|
assert_true(db.has_item("worn_shortsword"))
|
|
assert_true(db.has_item("coin"))
|
|
|
|
|
|
func test_companions_are_brannoc_and_cadwyn():
|
|
var ids := []
|
|
for n in db.companions():
|
|
ids.append(n["id"])
|
|
ids.sort()
|
|
assert_eq(ids, ["brannoc_thane","cadwyn_vell"])
|
|
|
|
|
|
func test_good_origin_has_no_unresolved_refs():
|
|
assert_eq(db.unresolved_refs(_deserter()), [])
|
|
|
|
|
|
func test_broken_location_ref_detected():
|
|
var o := _deserter()
|
|
o["start_location_id"] = "nowhere"
|
|
assert_true("location:nowhere" in db.unresolved_refs(o))
|
|
|
|
|
|
func test_broken_item_ref_detected():
|
|
var o := _deserter()
|
|
o["inventory_grants"] = o["inventory_grants"].duplicate(true)
|
|
o["inventory_grants"].append({"item_id": "ghost_blade", "qty": 1})
|
|
assert_true("item:ghost_blade" in db.unresolved_refs(o))
|
|
|
|
|
|
func test_null_quest_ref_resolves():
|
|
var o := _deserter()
|
|
o["start_quest_id"] = null
|
|
assert_eq(db.unresolved_refs(o), [])
|
|
|
|
|
|
func test_loads_canon_and_topics():
|
|
assert_true(db.has_canon("town.duncarrow"))
|
|
assert_true(db.has_canon("place.the-white-antlers"))
|
|
assert_true(db.has_topic("rumor.travelers-go-missing"))
|
|
|
|
|
|
func test_topic_skeleton_has_no_body():
|
|
var t: Dictionary = db.topic("secret.crell-runs-slave-trade")
|
|
assert_false(t.has("body")) # bodies are server-only
|
|
|
|
|
|
func test_legacy_npcs_still_load():
|
|
assert_true(db.has_npc("fenn"))
|
|
assert_true(db.has_npc("npc.mera-fenn"))
|