Skip to content

Commit

Permalink
Add test for non existent module declaration (#179)
Browse files Browse the repository at this point in the history
* Add a non existent module in setting gradle file to check to ensure it's supported

* Fix assertions in test result validation

The test assertion mechanism was updated in the project service validation tests. Instead of checking presence of every expected key into the result keys set individually, now the equality of sets is checked. Additionally, data for a non-existent module was added to the pkgs-test-java.json, this will help testing scenarios where the tested project doesn't have some prerequisites.

* Fix publication workflow
  • Loading branch information
fscarponi authored May 23, 2024
1 parent 16fc7f9 commit 5580885
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/publish-release.yml.disabled
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jobs:
name: Publish Package Search to Marketplace
runs-on: ubuntu-latest
env:
TOOLBOX_ENTERPRISE_TOKEN: ${{ secrets.TOOLBOX_ENTERPRISE_TOKEN }}
MARKETPLACE_TOKEN: ${{ secrets.MARKETPLACE_TOKEN }}
GRADLE_ENTERPRISE_KEY: ${{ secrets.GRADLE_ENTERPRISE_KEY }}
SPACE_INTELLIJ_NIGHTLIES_TOKEN: ${{ secrets.SPACE_INTELLIJ_NIGHTLIES_TOKEN }}
Expand All @@ -19,7 +20,6 @@ jobs:
RUN_NUMBER: ${{ github.run_number }}
RUN_ATTEMPT: ${{ github.run_attempt }}
CHANGE_NOTES: ${{ github.event.release.body }}
KMP: true
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -33,6 +33,8 @@ jobs:
- name: Publish libraries
run: ./gradlew publishAllPublicationsToSpaceRepository
- name: Publish release plugin to TBE
env:
KMP: true
run: ./gradlew :plugin:publishReleasePluginToTBE
- name: Publish plugin to Marketplace
run: ./gradlew :plugin:publishPluginToMarketplace
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,16 @@ internal fun TestScope.validateResult(projectName: String, expectedResultPath: S
"Deserialization of test result failed or is null for project $projectName"
)

val expectedKeys = expected.value?.keys ?: emptySet()
val resultKeys = result.value?.keys ?: emptySet()

assertTrue(expected.value?.keys?.all { it in (result.value?.keys ?: emptySet()) } ?: false,
assert(expectedKeys == resultKeys) {
buildString {
appendLine("expected MODULE keys differ from result keys")
appendLine("expected: ${expected.value?.keys}")
appendLine("result: ${result.value?.keys}")
}
)
}

expected.value?.forEach { (key, value) ->
assertNotNull(
Expand Down
21 changes: 21 additions & 0 deletions plugin/src/test/resources/projects/gradle/pkgs-test-java.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,27 @@
],
"defaultScope": "implementation"
},
"non_existent_module": {
"type": "com.jetbrains.packagesearch.plugin.tests.SerializablePackageSearchModule.Base",
"name": "non_existent_module",
"identity": {
"group": "gradle",
"path": ":non_existent_module"
},
"declaredRepositories": [],
"compatiblePackageTypes": [
{
"type": "maven"
},
{
"type": "gradle"
}
],
"dependencyMustHaveAScope": true,
"declaredDependencies": [],
"availableScopes": [],
"defaultScope": null
},
"sub-module-1": {
"type": "com.jetbrains.packagesearch.plugin.tests.SerializablePackageSearchModule.Base",
"name": "sub-module-1",
Expand Down

0 comments on commit 5580885

Please sign in to comment.