Skip to content

Commit

Permalink
Introduce back TestUtil.newTestId(String) (spotify#5183)
Browse files Browse the repository at this point in the history
  • Loading branch information
Michel Davit authored Jan 18, 2024
1 parent bc4ecfb commit d8764eb
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions scio-core/src/main/scala/com/spotify/scio/testing/TestUtil.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,17 @@ import java.util.UUID

private[scio] object TestUtil {

def newTestId(clazz: Class[_]): String = {
val className = clazz.getSimpleName
val uuid = UUID.randomUUID().toString.replaceAll("-", "")
s"JobTest-$className-$uuid"
def newTestId(): String = newTestId(None)
def newTestId(clazz: Class[_]): String = newTestId(clazz.getSimpleName)
def newTestId(name: String): String = {
require(name.nonEmpty && !name.contains('-'), s"Invalid test name $name")
newTestId(Some(name))
}
def newTestId(): String = {
val uuid = UUID.randomUUID().toString.replaceAll("-", "")
s"JobTest-$uuid"

private def newTestId(suffix: Option[String]): String = {
val id = UUID.randomUUID().toString.replaceAll("-", "")
val parts = Seq("JobTest") ++ suffix ++ Seq(id)
parts.mkString("-")
}

def isTestId(appName: String): Boolean =
Expand Down

0 comments on commit d8764eb

Please sign in to comment.