Skip to content

Commit

Permalink
Add unit tests for local editor filter_by_name_pattern. (#42)
Browse files Browse the repository at this point in the history
* Add unit tests for local editor filter_by_name_pattern.

* Add more test cases.

* fix name
  • Loading branch information
artsich authored Oct 19, 2023
1 parent b0fc226 commit 5a521f7
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/cases/services/assets/editors.cfg
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions tests/cases/services/local_editor_tests.gd
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 5a521f7

Please sign in to comment.