From 55808856ec41e6b092f2558424ce430e4f5459ee Mon Sep 17 00:00:00 2001 From: Fabrizio Scarponi <36624359+fscarponi@users.noreply.github.com> Date: Thu, 23 May 2024 20:20:07 +0200 Subject: [PATCH] Add test for non existent module declaration (#179) * 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 --- .../workflows/publish-release.yml.disabled | 4 +++- .../end2end/projectservice/Validation.kt | 6 ++++-- .../projects/gradle/pkgs-test-java.json | 21 +++++++++++++++++++ 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish-release.yml.disabled b/.github/workflows/publish-release.yml.disabled index 05020ea5..651d9df9 100644 --- a/.github/workflows/publish-release.yml.disabled +++ b/.github/workflows/publish-release.yml.disabled @@ -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 }} @@ -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: @@ -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 diff --git a/plugin/src/test/kotlin/com/jetbrains/packagesearch/plugin/tests/end2end/projectservice/Validation.kt b/plugin/src/test/kotlin/com/jetbrains/packagesearch/plugin/tests/end2end/projectservice/Validation.kt index a34f7dd7..70f29df7 100644 --- a/plugin/src/test/kotlin/com/jetbrains/packagesearch/plugin/tests/end2end/projectservice/Validation.kt +++ b/plugin/src/test/kotlin/com/jetbrains/packagesearch/plugin/tests/end2end/projectservice/Validation.kt @@ -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( diff --git a/plugin/src/test/resources/projects/gradle/pkgs-test-java.json b/plugin/src/test/resources/projects/gradle/pkgs-test-java.json index ba2bb414..6d396e5c 100644 --- a/plugin/src/test/resources/projects/gradle/pkgs-test-java.json +++ b/plugin/src/test/resources/projects/gradle/pkgs-test-java.json @@ -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",