Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jgainerdewar committed Oct 21, 2021
1 parent cfa707b commit 4feed63
Showing 1 changed file with 52 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package cromwell.backend.impl.tes

import common.assertion.CromwellTimeoutSpec
import cromwell.backend.BackendSpec
import cromwell.backend.validation.ContinueOnReturnCodeSet
import cromwell.core.WorkflowOptions
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers
import spray.json.{JsObject, JsString, JsValue}

class TesTaskSpec extends AnyFlatSpec with CromwellTimeoutSpec with Matchers with BackendSpec {

val runtimeAttributes = new TesRuntimeAttributes(
ContinueOnReturnCodeSet(Set(0)),
"ubuntu:latest",
None,
false,
None,
None,
None,
false
)

def workflowDescriptorWithIdentity(excIdentity: Option[String]) = {
val optionsMap: Map[String, JsValue] = excIdentity.map(i => TesWorkflowOptionKeys.Identity -> JsString(i)).toMap
buildWdlWorkflowDescriptor(TestWorkflows.HelloWorld, None, WorkflowOptions(JsObject(optionsMap)))
}

"TesTask" should "create the correct resources when an identity is passed in WorkflowOptions" in {
val wd = workflowDescriptorWithIdentity(Some("abc123"))
assert(
TesTask.makeResources(runtimeAttributes, wd)
== Resources(None, None, None, Some(false), None, Some(Map(TesWorkflowOptionKeys.Identity -> "abc123")))
)
}

"TesTask" should "create the correct resources when an empty identity is passed in WorkflowOptions" in {
val wd = workflowDescriptorWithIdentity(Some(""))
assert(
TesTask.makeResources(runtimeAttributes, wd)
== Resources(None, None, None, Some(false), None, Some(Map(TesWorkflowOptionKeys.Identity -> "")))
)
}

"TesTask" should "create the correct resources when no identity is passed in WorkflowOptions" in {
val wd = workflowDescriptorWithIdentity(None)
assert(
TesTask.makeResources(runtimeAttributes, wd)
== Resources(None, None, None, Some(false), None, None)
)
}
}

0 comments on commit 4feed63

Please sign in to comment.