Skip to content

Commit

Permalink
Merge branch 'void-functions' of https://github.com/bancek/scrooge
Browse files Browse the repository at this point in the history
  • Loading branch information
Chunyan Song committed Mar 18, 2013
2 parents bf94001 + 4855f16 commit e1e92d0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ private[this] object {{__stats_name}} {
None
{{/hasThrows}}
{{#void}}
Future.Done
exception.getOrElse(Future.Done)
{{/void}}
{{^void}}
exception.orElse(result.success.map(Future.value)).getOrElse(Future.exception(missingResult("{{clientFuncNameForWire}}")))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,17 @@ class ServiceGeneratorSpec extends SpecificationWithJUnit with EvalHelper with J
client.deliver("Boston")() mustEqual 42
}

"success void" in {
val request = encodeRequest("remove", ExceptionalService.RemoveArgs(123))
val response = encodeResponse("remove", ExceptionalService.RemoveResult())

expect {
one(impl).remove(123) willReturn Future.Done
}

client.remove(123)() mustEqual ()
}

"exception" in {
val request = encodeRequest("deliver", ExceptionalService.deliver$args("Boston"))
val ex = Xception(1, "boom")
Expand All @@ -252,6 +263,18 @@ class ServiceGeneratorSpec extends SpecificationWithJUnit with EvalHelper with J

client.deliver("Boston")() must throwA[ThriftException](ex)
}

"void exception" in {
val request = encodeRequest("remove", ExceptionalService.RemoveArgs(123))
val ex = Xception(1, "boom")
val response = encodeResponse("remove", ExceptionalService.RemoveResult(ex = Some(ex)))

expect {
one(impl).remove(123) willReturn Future.exception(ex)
}

client.remove(123)() must throwA[ThriftException](ex)
}
}

"correctly inherit traits across services" in {
Expand Down
6 changes: 6 additions & 0 deletions scrooge-generator/src/test/thrift/standalone/test.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,12 @@ service ExceptionalService {
2: Xception2 ex2
3: EmptyXception ex3
)

void remove(1: i32 id) throws (
1: Xception ex
2: Xception2 ex2
3: EmptyXception ex3
)
}

service ThriftTest
Expand Down

0 comments on commit e1e92d0

Please sign in to comment.