Skip to content

Commit d136db4

Browse files
committed
test: 🧪 added no callable set test
1 parent c26a4bf commit d136db4

File tree

4 files changed

+74
-0
lines changed

4 files changed

+74
-0
lines changed

test/Unit/test_options.gd

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@ func test_customize_script() -> void:
1818
)
1919

2020

21+
func test_customize_script_no_callable() -> void:
22+
# Clear saved error logs before testing to prevent false positives.
23+
ModLoaderLog.logged_messages.by_type.error.clear()
24+
25+
ModLoaderStore._update_ml_options_from_options_resource("res://test_options/customize_script_no_callable_set/options_custom_validation_no_callable_set.tres")
26+
var manifest := load_manifest_test_mod_1()
27+
28+
var logs := ModLoaderLog.get_by_type_as_string("error")
29+
30+
assert_string_contains("".join(logs), "No custom game version validation callable detected. Please provide a valid validation callable.")
31+
32+
2133
func test_game_verion_validation_disabled() -> void:
2234
ModLoaderStore._update_ml_options_from_options_resource("res://test_options/game_version_validation_disabled/options_game_version_validation_disabled.tres")
2335
var manifest := load_manifest_test_mod_1()
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[gd_resource type="Resource" script_class="ModLoaderOptionsProfile" load_steps=2 format=3 uid="uid://1gab2n8lgi60"]
2+
3+
[ext_resource type="Script" path="res://addons/mod_loader/resources/options_profile.gd" id="1_d2tfu"]
4+
5+
[resource]
6+
script = ExtResource("1_d2tfu")
7+
enable_mods = true
8+
locked_mods = Array[String]([])
9+
disabled_mods = Array[String]([])
10+
allow_modloader_autoloads_anywhere = false
11+
customize_script_path = "res://test_options/customize_script_no_callable_set/customize_script_no_callable_set.gd"
12+
log_level = 3
13+
ignore_deprecated_errors = false
14+
ignored_mod_names_in_log = Array[String]([])
15+
steam_id = 0
16+
semantic_version = "0.0.0"
17+
load_from_steam_workshop = false
18+
load_from_local = true
19+
override_path_to_mods = ""
20+
override_path_to_configs = ""
21+
override_path_to_workshop = ""
22+
override_path_to_hook_pack = ""
23+
override_hook_pack_name = ""
24+
restart_notification_scene_path = "res://addons/mod_loader/restart_notification.tscn"
25+
disable_restart = false
26+
game_version_validation = 2
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
extends RefCounted
2+
3+
# This is an example script for the ModLoaderOptionsProfile `customize_script_path`.
4+
# Ideally, place this script outside the `mod_loader` directory to simplify the update process.
5+
6+
7+
# This script is loaded after `mod_loader_store.ml_options` has been initialized.
8+
# It receives `ml_options` as an argument, allowing you to apply settings
9+
# that cannot be configured through the editor UI.
10+
func _init(ml_options: ModLoaderOptionsProfile) -> void:
11+
# Use OS.has_feature() to apply changes only for specific platforms,
12+
# or create multiple customization scripts and set their paths accordingly in the option profiles.
13+
if OS.has_feature("Steam"):
14+
pass
15+
elif OS.has_feature("Epic"):
16+
pass
17+
else:
18+
pass
19+
# Set `custom_game_version_validation_callable` to use a custom validation function.
20+
#ml_options.custom_game_version_validation_callable = custom_is_game_version_compatible
21+
22+
23+
# Custom validation function
24+
# See `ModManifest._is_game_version_compatible()` for the default validation logic.
25+
func custom_is_game_version_compatible(manifest: ModManifest) -> bool:
26+
manifest.validation_messages_warning.push_back("! ☞゚ヮ゚)☞ CUSTOM VALIDATION HERE ☜゚ヮ゚☜) !")
27+
return true
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[gd_resource type="Resource" script_class="ModLoaderCurrentOptions" load_steps=3 format=3 uid="uid://c25j7kt7y8ora"]
2+
3+
[ext_resource type="Resource" uid="uid://1gab2n8lgi60" path="res://test_options/customize_script_no_callable_set/custom_validation_no_callable_set.tres" id="1_xrqi6"]
4+
[ext_resource type="Script" path="res://addons/mod_loader/resources/options_current.gd" id="2_4o6bw"]
5+
6+
[resource]
7+
script = ExtResource("2_4o6bw")
8+
current_options = ExtResource("1_xrqi6")
9+
feature_override_options = {}

0 commit comments

Comments
 (0)