From 5a521f7e8581c944a6ddd31a1077667e8e07c92b Mon Sep 17 00:00:00 2001 From: Artsiom Dubinevich <34747326+JillyMan@users.noreply.github.com> Date: Thu, 19 Oct 2023 10:04:47 -0700 Subject: [PATCH] Add unit tests for local editor filter_by_name_pattern. (#42) * Add unit tests for local editor filter_by_name_pattern. * Add more test cases. * fix name --- tests/cases/services/assets/editors.cfg | 14 ++++++++++++++ tests/cases/services/local_editor_tests.gd | 17 +++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 tests/cases/services/assets/editors.cfg create mode 100644 tests/cases/services/local_editor_tests.gd diff --git a/tests/cases/services/assets/editors.cfg b/tests/cases/services/assets/editors.cfg new file mode 100644 index 00000000..89809a9e --- /dev/null +++ b/tests/cases/services/assets/editors.cfg @@ -0,0 +1,14 @@ +[C:/Users/user/AppData/Roaming/Godot/app_userdata/Godots/versions/Godot_v4_1_1-stable_win64_exe/Godot_v4.1.1-stable_win64.exe] + +name="Godot v4.1.1 stable" +favorite=false + +[C:/Users/user/AppData/Roaming/Godot/app_userdata/Godots/versions/Godot_v4_1_2-stable_win64_exe/Godot_v4.1.2-stable_win64.exe] + +name="Godot v4.1.2 stable" +favorite=false + +[C:/Users/user/AppData/Roaming/Godot/app_userdata/Godots/versions/Godot_v4_1-stable_win64_exe/Godot_v4.1-stable_win64.exe] + +name="Godot v4.1 stable" +favorite=false diff --git a/tests/cases/services/local_editor_tests.gd b/tests/cases/services/local_editor_tests.gd new file mode 100644 index 00000000..92e13313 --- /dev/null +++ b/tests/cases/services/local_editor_tests.gd @@ -0,0 +1,17 @@ +class_name LocalEditorTests +extends GdUnitTestSuite + +const config_path = "res://tests/cases/services/assets/editors.cfg" + +func test_filter_by_name_pattern(name: String, expected: int, test_parameters:= [ + ["4.1", 3], + ["4.1s", 1], + ["4.1 s", 1], + [" 4.1 s", 1], + ["4.1 StAble", 1], + ["invalid", 0], +]): + var editors = LocalEditors.List.new(config_path) + editors.load() + var result = editors.filter_by_name_pattern(name) + assert(result.size() == expected)