Skip to content

Commit

Permalink
Update CbasClientSpec.scala
Browse files Browse the repository at this point in the history
  • Loading branch information
zykonda committed Nov 9, 2023
1 parent 3cc0708 commit bc18b24
Showing 1 changed file with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,20 @@ class CbasClientSpec extends AnyFlatSpec with Matchers with RequestResponsePactF
)

val bearerToken = "my-token"
val workflowId = "33333333-3333-3333-3333-333333333333"
val state = "Aborted"
val outputs = "[]"
val workflowId = "12345678-1234-1234-1111-111111111111"
val completedState = "Succeeded"
val workflowOutputs =
"""
{
"wf_hello.hello.salutations": "Hello batch!"
}
"""
val failures = List.empty[String]

val updateRequestDsl = newJsonBody { o =>
val updateCompletedRunDsl = newJsonBody { o =>
o.stringType("workflowId", workflowId)
o.stringType("state", state)
o.stringType("outputs", outputs)
o.stringType("state", completedState)
o.stringType("outputs", workflowOutputs)
o.array("failures",
{ f =>
failures.foreach(f.stringType)
Expand All @@ -51,18 +56,17 @@ class CbasClientSpec extends AnyFlatSpec with Matchers with RequestResponsePactF
val pactProvider: PactDslWithProvider = consumerPactBuilder
.hasPactWith("cbas")


var pactDslResponse: PactDslResponse = buildInteraction(
var pactUpdateCompletedRunDslResponse: PactDslResponse = buildInteraction(
pactProvider,
state = "post workflow results",
state = "post completed workflow results",
uponReceiving = "Request to post workflow results",
method = "POST",
path = "/api/batch/v1/runs/results",
requestHeaders = Seq("Authorization" -> "Bearer %s".formatted(bearerToken), "Content-type" -> "application/json"),
requestBody = updateRequestDsl,
requestBody = updateCompletedRunDsl,
status = 200
)
override val pact: RequestResponsePact = pactDslResponse.toPact
override val pact: RequestResponsePact = pactUpdateCompletedRunDslResponse.toPact

val client: Client[IO] = {
BlazeClientBuilder[IO](ExecutionContext.global).resource.allocated.unsafeRunSync()._1
Expand All @@ -72,9 +76,9 @@ class CbasClientSpec extends AnyFlatSpec with Matchers with RequestResponsePactF
new CbasClientImpl[IO](client, Uri.unsafeFromString(mockServer.getUrl))
.postWorkflowResults(
Authorization(Credentials.Token(AuthScheme.Bearer, bearerToken)),
WorkflowCallbackMessage(workflowId, state, Map.empty, failures)
WorkflowCallbackMessage(workflowId, completedState, workflowOutputs, failures)
)
.attempt
.unsafeRunSync() shouldBe Right(true)
}
}
}

0 comments on commit bc18b24

Please sign in to comment.