Created
January 18, 2017 06:27
-
-
Save ioleo/cb490d7f379e5f9b4b0db13ee0a51e33 to your computer and use it in GitHub Desktop.
Quill CassandraAsyncContext with stubbed underlaying Cluster - does not try to connect on init. Useful as a mock in tests.
This file contains hidden or 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 is a disabled version of CassandraAsyncContext which does not connect to Cassandra DB on init | |
package loostro.scala.gist | |
import collection.JavaConverters._ | |
import com.datastax.driver.core.Cluster | |
import com.datastax.driver.core.Configuration.Builder | |
import io.getquill.{CassandraAsyncContext, SnakeCase} | |
import java.net.InetSocketAddress | |
import org.scalatest.{FlatSpec, Matchers} | |
import org.scalamock.scalatest.MockFactory | |
import scala.collection.mutable._ | |
trait CassandraDbSpec extends FlatSpec with Matchers with MockFactory { spec => | |
class CassandraClusterTest extends Cluster("none", ArrayBuffer[InetSocketAddress]().asJava, new Builder().build()) | |
val clusterStub = stub[CassandraClusterTest] | |
// any class requireing CassandraAsyncContext (eg. repositories) will consume this implicit mock | |
implicit val db: CassandraAsyncContext[SnakeCase] = new CassandraAsyncContext[SnakeCase](clusterStub, "none", 0) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment