Skip to content

Conversation

@Blade67
Copy link
Contributor

@Blade67 Blade67 commented Mar 7, 2023

Adds validation function validate_dependencies_and_incompatibilities_conflicts() to mod_manifest.gd

Validates a mod's dependencies and incompatibilities to ensure they don't conflict.

closes #169

@Blade67 Blade67 changed the base branch from main to development March 7, 2023 17:25
@Blade67 Blade67 requested a review from KANAjetzt March 7, 2023 17:25
@Blade67 Blade67 changed the title #169 (untested) Fix: Add a check if the same Mod ID is in dependencies and incompatibilities Mar 7, 2023
Copy link
Collaborator

@Qubus0 Qubus0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good so far, pls test

@KANAjetzt KANAjetzt added enhancement New feature or request validation Feature to make things safe and predictable labels Mar 7, 2023
Changed the function name `has_overlaps()` -> `validate_dependencies_and_incompatibilities_conflicts()` | Changed the log text to include the mod id | Calling the function in `_init()` instead of `validate_dependencies_and_incompatibilities()`
@KANAjetzt
Copy link
Member

KANAjetzt commented Mar 28, 2023

I actually generated some unit tests for this 👀
Just to see if it works.

Also tested it "by hand" and works fine.
image

Tests
extends "res://addons/gut/test.gd"


func test_validate_dependencies_and_incompatibilities_conflicts():
	# Test when there are no overlaps between dependencies and incompatibilities
	var mod_id = "test-mod"
	var dependencies = PoolStringArray(["mod1-mod1", "mod2-mod2"])
	var incompatibilities = PoolStringArray(["mod3-mod3", "mod4-mod4"])
	var result = ModManifest.validate_dependencies_and_incompatibilities_conflicts(mod_id, dependencies, incompatibilities)
	assert_eq(result, false)

	# Test when there is an overlap between dependencies and incompatibilities
	mod_id = "test-mod2"
	dependencies = PoolStringArray(["mod1-mod1", "mod2-mod2", "mod3-mod3"])
	incompatibilities = PoolStringArray(["mod3-mod3", "mod4-mod4"])
	result = ModManifest.validate_dependencies_and_incompatibilities_conflicts(mod_id, dependencies, incompatibilities, true)
	assert_eq(result, true)

	# Test when the function is called with no incompatibilities
	mod_id = "test-mod3"
	dependencies = PoolStringArray(["mod1-mod1", "mod2-mod2", "mod3-mod3"])
	incompatibilities = PoolStringArray([])
	result = ModManifest.validate_dependencies_and_incompatibilities_conflicts(mod_id, dependencies, incompatibilities)
	assert_eq(result, false)

	# Test when the function is called with no dependencies
	mod_id = "test-mod4"
	dependencies = PoolStringArray([])
	incompatibilities = PoolStringArray(["mod1-mod1", "mod2-mod2"])
	result = ModManifest.validate_dependencies_and_incompatibilities_conflicts(mod_id, dependencies, incompatibilities)
	assert_eq(result, false)

@KANAjetzt KANAjetzt changed the title Fix: Add a check if the same Mod ID is in dependencies and incompatibilities Fix: ♻️ Mod-Id in dependencies and incompatibilities Mar 28, 2023
@KANAjetzt KANAjetzt changed the title Fix: ♻️ Mod-Id in dependencies and incompatibilities Fix: ♻️ ModID in dependencies and incompatibilities Mar 28, 2023
Copy link
Collaborator

@Qubus0 Qubus0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, thanks. not sure if we need it but technically, an incompatibility should also not be an optional dependency. might not be in the scope here since the optional ones were added after this issue

@KANAjetzt KANAjetzt added this to the v6.0.0 milestone Mar 28, 2023
@KANAjetzt KANAjetzt changed the title Fix: ♻️ ModID in dependencies and incompatibilities fix: ♻️ ModID in dependencies and incompatibilities Mar 28, 2023
@KANAjetzt KANAjetzt added this pull request to the merge queue Mar 28, 2023
Merged via the queue into GodotModding:development with commit bf5f705 Mar 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request validation Feature to make things safe and predictable

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants