Skip to content

Commit

Permalink
feat(task): Add wait for taskID (#439)
Browse files Browse the repository at this point in the history
  • Loading branch information
ElPicador committed Jan 3, 2018
1 parent 126b7ac commit 6953bab
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ trait WaitForTaskDsl {
case object waitFor {
def task(task: AlgoliaTask): WaitForTaskDefinition =
WaitForTaskDefinition(task.idToWaitFor())

def task(taskID: Long): WaitForTaskDefinition =
WaitForTaskDefinition(taskID)
}

implicit object WaitForTaskDefinitionExecutable
Expand Down
15 changes: 15 additions & 0 deletions src/test/scala/algolia/dsl/WaitForTaskTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ class WaitForTaskTest extends AlgoliaTest {
waitFor task Task(1L, None) from "toto" baseDelay 5 maxDelay 100
}

it("wait for a taskId") {
waitFor task 1L from "toto" baseDelay 5 maxDelay 100
}

it("should call API") {
(waitFor task Task(1L, None) from "toto").build() should be(
HttpPayload(
Expand All @@ -48,6 +52,17 @@ class WaitForTaskTest extends AlgoliaTest {
)
)
}

it("should call API for a taskID") {
(waitFor task 1L from "toto").build() should be(
HttpPayload(
GET,
Seq("1", "indexes", "toto", "task", "1"),
isSearch = true,
requestOptions = None
)
)
}
}

}

0 comments on commit 6953bab

Please sign in to comment.