Skip to content

Commit

Permalink
Add test util for locating a subproject 2 layers deep
Browse files Browse the repository at this point in the history
  • Loading branch information
SarahFrench committed Feb 16, 2024
1 parent 0c871aa commit d9b04fd
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions mmv1/third_party/terraform/.teamcity/tests/test_utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
package tests

import builds.AllContextParameters
import jetbrains.buildServer.configs.kotlin.Project
import org.junit.Assert

const val gaProjectName = "Google"
const val betaProjectName = "Google Beta"
Expand Down Expand Up @@ -49,4 +51,19 @@ fun testContextParameters(): AllContextParameters {
"zone",
"infraProject",
"vcrBucketName")
}

fun getSubProject(rootProject: Project, parentProjectName: String, subProjectName: String): Project? {
// Find parent project within root
var parentProject: Project? = rootProject.subProjects.find { p-> p.name == parentProjectName}
if (parentProject == null) {
Assert.fail("Could not find the $parentProjectName project")
}
// Find subproject within parent identified above
var subProject: Project? = parentProject!!.subProjects.find { p-> p.name == subProjectName}
if (subProject == null) {
Assert.fail("Could not find the $subProjectName project")
}

return subProject
}

0 comments on commit d9b04fd

Please sign in to comment.