-
Notifications
You must be signed in to change notification settings - Fork 408
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit '1d6e4df1e3255d1757ee7e9dcc1e705651d9b122'
- Loading branch information
Showing
20 changed files
with
3,019 additions
and
1,931 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Changelog | ||
========= | ||
|
||
Below is a list of changes for each Finatra release. | ||
|
||
|
||
.. include:: ../../../CHANGELOG.rst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
inject/inject-core/src/test/scala/com/twitter/inject/WhenReadyMixin.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.twitter.inject | ||
|
||
import com.twitter.util.{Duration, Future, Return, Throw} | ||
import org.scalatest.concurrent.PatienceConfiguration.{Interval, Timeout} | ||
import org.scalatest.concurrent.ScalaFutures.{FutureConcept, PatienceConfig} | ||
import org.scalatest.time.{Millis, Seconds, Span} | ||
import scala.language.implicitConversions | ||
|
||
/** | ||
* ScalaTest provides a whenReady function that handles async computations. whenReady takes | ||
* a FutureConcept and an implicit PatienceConfig as parameters. Extend this trait in your | ||
* test to get an implicit conversion from a Twitter Future to a FutureConcept. It also provides | ||
* a default PatienceConfig which you can override in your test to suit your needs. | ||
* | ||
* @see <a href="http://doc.scalatest.org/3.0.0/index.html#org.scalatest.concurrent.ScalaFutures">ScalaFutures</a> | ||
*/ | ||
trait WhenReadyMixin { | ||
protected implicit val patienceConfig = | ||
PatienceConfig(timeout = Span(5, Seconds), interval = Span(20, Millis)) | ||
|
||
final protected implicit def convertTwitterFuture[T](twitterFuture: Future[T]): FutureConcept[T] = | ||
new FutureConcept[T] { | ||
def eitherValue: Option[Either[Throwable, T]] = | ||
twitterFuture.poll.map { | ||
case Return(result) => Right(result) | ||
case Throw(e) => Left(e) | ||
} | ||
// As per the ScalaTest docs if the underlying future does not support these they | ||
// must return false. | ||
def isExpired: Boolean = false | ||
def isCanceled: Boolean = false | ||
} | ||
|
||
final implicit def twitterDurationToScalaTestTimeout(duration: Duration): Timeout = { | ||
Timeout(Span(duration.inMillis, Millis)) | ||
} | ||
|
||
final implicit def twitterDurationToScalaTestInterval(duration: Duration): Interval = { | ||
Interval(Span(duration.inMillis, Millis)) | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
inject/inject-core/src/test/scala/com/twitter/inject/tests/WhenReadyMixinTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.twitter.inject.tests | ||
|
||
import com.twitter.conversions.time._ | ||
import com.twitter.inject.{Test, WhenReadyMixin} | ||
import com.twitter.util.Future | ||
import org.scalatest.concurrent.ScalaFutures._ | ||
|
||
class WhenReadyMixinTest extends Test with WhenReadyMixin { | ||
test("should be able to use ScalaTest's whenReady with a Twitter Future") { | ||
whenReady(Future.apply("Test it")) { result => | ||
result should be("Test it") | ||
} | ||
} | ||
|
||
test( | ||
"should be able to use a twitter Duration for the timeout" | ||
) { | ||
whenReady(Future.apply("Test it"), timeout = 5.seconds) { result => | ||
result should be("Test it") | ||
} | ||
} | ||
|
||
test( | ||
"should be able to use a twitter Duration for the interval" | ||
) { | ||
whenReady(Future.apply("Test it"), interval = 10.milliseconds) { result => | ||
result should be("Test it") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters