Skip to content

Commit

Permalink
Add tests for zero parameter lists
Browse files Browse the repository at this point in the history
  • Loading branch information
kubukoz committed Feb 3, 2024
1 parent 76701c9 commit 44a59f9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
14 changes: 14 additions & 0 deletions core/src/test/scala/respectfully/test/ClientTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,20 @@ object ClientTests extends SimpleIOSuite {
}
}

test("one op without parameter lists") {
trait SimpleApi derives API {
def op: IO[Int]
}

fakeClient(42).flatMap { (client, uri, captured) =>
API[SimpleApi].toClient(client, uri).op.map(assert.eql(42, _)) *>
captured.map { req =>
assert.eql("op", methodHeader(req)) &&
succeed(bodyJsonDecode[Unit](req))
}
}
}

test("one op with param") {
trait SimpleApi derives API {
def operation(a: Int): IO[String]
Expand Down
16 changes: 16 additions & 0 deletions core/src/test/scala/respectfully/test/ServerTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,22 @@ object ServerTests extends SimpleIOSuite {
.flatMap(assertSuccess(_, 42))
}

test("one op without parameter lists") {
trait SimpleApi derives API {
def op: IO[Int]
}

val impl: SimpleApi =
new SimpleApi {
def op: IO[Int] = IO.pure(42)
}

API[SimpleApi]
.toRoutes(impl)
.run(request("op")(JsonObject.empty))
.flatMap(assertSuccess(_, 42))
}

test("one op with param") {
trait SimpleApi derives API {
def operation(a: Int): IO[Int]
Expand Down

0 comments on commit 44a59f9

Please sign in to comment.