From dcfac94df78fa64937cadbbc7e30c6aedc7df292 Mon Sep 17 00:00:00 2001 From: Martin Hauner Date: Thu, 19 Dec 2024 16:31:29 +0100 Subject: [PATCH] fix test --- .../intellij/support/TargetPackageFinderStub.kt | 5 ++--- .../TargetPackageFinderTest.kt | 15 ++++++++++----- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/test/kotlin/io/openapiprocessor/intellij/support/TargetPackageFinderStub.kt b/src/test/kotlin/io/openapiprocessor/intellij/support/TargetPackageFinderStub.kt index 6e5831eb..eab018be 100644 --- a/src/test/kotlin/io/openapiprocessor/intellij/support/TargetPackageFinderStub.kt +++ b/src/test/kotlin/io/openapiprocessor/intellij/support/TargetPackageFinderStub.kt @@ -11,8 +11,7 @@ import io.openapiprocessor.intellij.TargetPackageFinder class TargetPackageFinderStub(private val pkg: PsiDirectory?) : TargetPackageFinder { - override fun findPackageDir(pkgName: String, mappingModule: Module): PsiDirectory? { - return pkg + override fun findPackageDirs(pkgName: String, mappingModule: Module): List { + return if (pkg == null) emptyList() else listOf(pkg) } - } diff --git a/src/test/kotlin/io/openapiprocessor/intellij/targetpackagefinder/TargetPackageFinderTest.kt b/src/test/kotlin/io/openapiprocessor/intellij/targetpackagefinder/TargetPackageFinderTest.kt index 0d73c853..88d08d52 100644 --- a/src/test/kotlin/io/openapiprocessor/intellij/targetpackagefinder/TargetPackageFinderTest.kt +++ b/src/test/kotlin/io/openapiprocessor/intellij/targetpackagefinder/TargetPackageFinderTest.kt @@ -7,6 +7,8 @@ package io.openapiprocessor.intellij.targetpackagefinder import com.intellij.openapi.components.service import com.intellij.openapi.module.ModuleUtil +import io.kotest.matchers.collections.shouldContainAll +import io.kotest.matchers.collections.shouldHaveSize import io.openapiprocessor.intellij.TargetPackageService import io.openapiprocessor.intellij.support.HeavyBaseTestCase @@ -23,7 +25,7 @@ class TargetPackageFinderTest: HeavyBaseTestCase() { } @SimpleModules - fun `test finds target package directory`() { + fun `test finds target package directories`() { val mapping = getBaseRelativePsiFile("src/api/mapping.yaml") val module = ModuleUtil.findModuleForFile(mapping)!! @@ -33,9 +35,12 @@ class TargetPackageFinderTest: HeavyBaseTestCase() { .findPackageDirs("io.openapiprocessor", module) // then - val target = targets.first() - val expected = getBaseRelativePsiDir("build/openapi/io/openapiprocessor") - assertEquals(expected.virtualFile.path, target.virtualFile.path) - } + targets.shouldHaveSize(3) + + val expectedMain = getBaseRelativePsiDir("src/main/io/openapiprocessor") + val expectedTest = getBaseRelativePsiDir("src/test/io/openapiprocessor") + val expectedApi = getBaseRelativePsiDir("build/openapi/io/openapiprocessor") + targets.shouldContainAll(expectedMain, expectedTest, expectedApi) + } }