extends "res://addons/gut/test.gd" ## The canon log crosses the HTTP boundary, so its roster exists twice: in code ## (Callings.IDS / Races.IDS) and in the JSON Schema the API validates against. ## Nothing at runtime reconciles them. This does. const ContentDB = preload("res://scripts/content/content_db.gd") func _player_schema() -> Dictionary: var path := ProjectSettings.globalize_path("res://") \ .path_join("../docs/schemas/canon-log.schema.json").simplify_path() var doc: Variant = ContentDB.load_json(path) assert_eq(typeof(doc), TYPE_DICTIONARY, "canon-log schema did not parse") return doc["properties"]["player"] func test_schema_calling_enum_matches_the_code(): var enum_ids: Array = _player_schema()["properties"]["calling_id"]["enum"] enum_ids.sort() var code_ids: Array = Callings.IDS.duplicate() code_ids.sort() assert_eq(enum_ids, code_ids) func test_schema_race_enum_matches_the_code(): var enum_ids: Array = _player_schema()["properties"]["race_id"]["enum"] enum_ids.sort() var code_ids: Array = Races.IDS.duplicate() code_ids.sort() assert_eq(enum_ids, code_ids) func test_schema_requires_race_and_calling(): var required: Array = _player_schema()["required"] assert_true("race_id" in required) assert_true("calling_id" in required) assert_false("class_id" in required, "class_id is the rulebook's word — it is gone")