Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'void-functions' of https://github.com/bancek/scrooge

  • Loading branch information...
commit e1e92d0ac7916ad62d9c388aa37f395a1dde9547 2 parents bf94001 + 4855f16
@chunyan authored
View
2  scrooge-generator/src/main/resources/scalagen/finagleClientFunction.scala
@@ -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}}")))
View
23 scrooge-generator/src/test/scala/com/twitter/scrooge/backend/ServiceGeneratorSpec.scala
@@ -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")
@@ -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 {
View
6 scrooge-generator/src/test/thrift/standalone/test.thrift
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.