Skip to content

Commit

Permalink
test(go): Factor out testDir
Browse files Browse the repository at this point in the history
Signed-off-by: Frank Viernau <[email protected]>
  • Loading branch information
fviernau committed Nov 1, 2023
1 parent 2c94e3b commit caecbea
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions plugins/package-managers/go/src/funTest/kotlin/GoDepFunTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,20 @@ import org.ossreviewtoolkit.utils.test.getAssetFile
import org.ossreviewtoolkit.utils.test.matchExpectedResult

class GoDepFunTest : WordSpec({
val testDir = getAssetFile("projects/synthetic/godep")

"GoDep" should {
"resolve dependencies from a lockfile correctly" {
val definitionFile = getAssetFile("projects/synthetic/godep/lockfile/Gopkg.toml")
val expectedResultFile = getAssetFile("projects/synthetic/godep/lockfile-expected-output.yml")
val definitionFile = testDir.resolve("lockfile/Gopkg.toml")
val expectedResultFile = testDir.resolve("lockfile-expected-output.yml")

val result = create("GoDep").resolveSingleProject(definitionFile)

result.toYaml() should matchExpectedResult(expectedResultFile, definitionFile)
}

"show error if no lockfile is present" {
val definitionFile = getAssetFile("projects/synthetic/godep/no-lockfile/Gopkg.toml")
val definitionFile = testDir.resolve("no-lockfile/Gopkg.toml")

val result = create("GoDep").resolveSingleProject(definitionFile)

Expand All @@ -66,7 +68,7 @@ class GoDepFunTest : WordSpec({
}

"invoke the dependency solver if no lockfile is present and allowDynamicVersions is set" {
val definitionFile = getAssetFile("projects/synthetic/godep/no-lockfile/Gopkg.toml")
val definitionFile = testDir.resolve("no-lockfile/Gopkg.toml")

val result = create("GoDep", allowDynamicVersions = true).resolveSingleProject(definitionFile)

Expand All @@ -77,17 +79,17 @@ class GoDepFunTest : WordSpec({
}

"import dependencies from Glide" {
val definitionFile = getAssetFile("projects/synthetic/godep/glide/glide.yaml")
val expectedResultFile = getAssetFile("projects/synthetic/godep/glide-expected-output.yml")
val definitionFile = testDir.resolve("glide/glide.yaml")
val expectedResultFile = testDir.resolve("glide-expected-output.yml")

val result = create("GoDep").resolveSingleProject(definitionFile)

result.toYaml() should matchExpectedResult(expectedResultFile, definitionFile)
}

"import dependencies from godeps" {
val definitionFile = getAssetFile("projects/synthetic/godep/godeps/Godeps/Godeps.json")
val expectedResultFile = getAssetFile("projects/synthetic/godep/godeps-expected-output.yml")
val definitionFile = testDir.resolve("godeps/Godeps/Godeps.json")
val expectedResultFile = testDir.resolve("godeps-expected-output.yml")

val result = create("GoDep").resolveSingleProject(definitionFile)

Expand Down

0 comments on commit caecbea

Please sign in to comment.