Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
hauner committed Dec 19, 2024
1 parent 40b33b1 commit dcfac94
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<PsiDirectory> {
return if (pkg == null) emptyList() else listOf(pkg)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)!!

Expand All @@ -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)
}
}

0 comments on commit dcfac94

Please sign in to comment.