Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ lazy val commonSettings: Seq[Setting[_]] = Seq(
organization := "net.debasishg",
version := "3.42",
scalaVersion := "2.13.7",
crossScalaVersions := Seq("2.13.7", "2.12.14", "2.11.12", "2.10.7"),
crossScalaVersions := Seq("2.13.7", "2.12.14", "2.11.12", "2.10.7", "3.0.2"),

Compile / scalacOptions ++= Seq( "-unchecked", "-feature", "-language:postfixOps", "-deprecation" ),

Expand All @@ -15,8 +15,11 @@ lazy val commonSettings: Seq[Setting[_]] = Seq(
)
)

def dockerTestKit(version: String): Seq[ModuleID] = {
Seq("docker-testkit-scalatest", "docker-testkit-impl-docker-java").map("com.whisk" %% _ % version % Test) :+
def dockerTestKit(version: String, dockerJavaV: Option[String] = None): Seq[ModuleID] = {
Seq(
"com.whisk" %% "docker-testkit-scalatest" % version % Test,
"com.whisk" %% "docker-testkit-impl-docker-java" % dockerJavaV.getOrElse(version) % Test
) :+
// https://github.com/eclipse-ee4j/jaxb-ri/issues/1222
"javax.xml.bind" % "jaxb-api" % "2.3.1" % Test
}
Expand All @@ -28,11 +31,11 @@ lazy val coreSettings = commonSettings ++ Seq(
"org.slf4j" % "slf4j-api" % "1.7.32",
"org.slf4j" % "slf4j-log4j12" % "1.7.32" % "provided",
"log4j" % "log4j" % "1.2.17" % "provided",
"org.scalatest" %% "scalatest" % "3.1.0" % "test"
"org.scalatest" %% "scalatest" % "3.2.9" % Test
) ++
(scalaBinaryVersion.value match {
case "2.10" => dockerTestKit("0.9.8")
case _ => dockerTestKit("0.9.9")
case _ => dockerTestKit("0.11.0", Some("0.11.0-beta1"))
})
,

Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/com/redis/ds/Deque.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ trait Deque[A] {
def size: Long
}

import com.redis.ListOperations
import com.redis.{ListOperations, Redis}
import com.redis.serialization.Parse.Implicits._
import com.redis.serialization._

trait RedisDeque[A]
extends Deque[A] { self: ListOperations =>
extends Deque[A] { self: ListOperations with Redis =>

val blocking: Boolean = false
val timeoutInSecs: Int = 0
Expand Down
2 changes: 1 addition & 1 deletion src/test/scala/com/redis/PatternsSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class PatternsSpec extends AnyFunSpec
with BeforeAndAfterEach
with RedisDocker {

implicit lazy val clients = new RedisClientPool(redisContainerHost, redisContainerPort)
implicit lazy val clients: RedisClientPool = new RedisClientPool(redisContainerHost, redisContainerPort)

override def afterEach() = clients.withClient{
client => client.flushdb
Expand Down
23 changes: 14 additions & 9 deletions src/test/scala/com/redis/SerializationSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,18 @@ class SerializationSpec extends AnyFunSpec

r.hmget("hash", "field1", "field2") should be(Some(Map("field1" -> "1", "field2" -> "2")))

implicit val parseInt = Parse[Int](new String(_).toInt)
{
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without these brackets, the earlier call to r.hmset will error in scala 3.0.2 with a message about an incorrect forwards-reference to parseInt

implicit val parseInt: Parse[Int] = Parse[Int](new String(_).toInt)

r.hmget[String,Int]("hash", "field1", "field2") should be(Some(Map("field1" -> 1, "field2" -> 2)))
r.hmget[String,String]("hash", "field1", "field2") should be(Some(Map("field1" -> "1", "field2" -> "2")))
r.hmget[String,Int]("hash", "field1", "field2", "field3") should be(Some(Map("field1" -> 1, "field2" -> 2)))
r.hmget[String, Int]("hash", "field1", "field2") should be(Some(Map("field1" -> 1, "field2" -> 2)))
r.hmget[String, String]("hash", "field1", "field2") should be(Some(Map("field1" -> "1", "field2" -> "2")))
r.hmget[String, Int]("hash", "field1", "field2", "field3") should be(Some(Map("field1" -> 1, "field2" -> 2)))
}
}

it("should use a provided implicit string parser") {
import Parse.Implicits.parseInt
implicit val parseString = Parse[String](new String(_).toInt.toBinaryString)
implicit val parseString: Parse[String] = Parse[String](new String(_).toInt.toBinaryString)
r.hmset("hash", Map("field1" -> "1", "field2" -> 2))
r.hmget[String,Int]("hash", "field1", "field2") should be(Some(Map("field1" -> 1, "field2" -> 2)))
r.hmget[String,String]("hash", "field1", "field2") should be(Some(Map("field1" -> "1", "field2" -> "10")))
Expand All @@ -52,10 +54,13 @@ class SerializationSpec extends AnyFunSpec
it("should use a provided implicit formatter") {
case class Upper(s: String)
r.hmset("hash1", Map("field1" -> Upper("val1"), "field2" -> Upper("val2")))
implicit val format = Format{case Upper(s) => s.toUpperCase}
r.hmset("hash2", Map("field1" -> Upper("val1"), "field2" -> Upper("val2")))
r.hmget("hash1", "field1", "field2") should be(Some(Map("field1" -> "Upper(val1)", "field2" -> "Upper(val2)")))
r.hmget("hash2", "field1", "field2") should be(Some(Map("field1" -> "VAL1", "field2" -> "VAL2")))

{
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

implicit val format: Format = Format{case Upper(s) => s.toUpperCase}
r.hmset("hash2", Map("field1" -> Upper("val1"), "field2" -> Upper("val2")))
r.hmget("hash1", "field1", "field2") should be(Some(Map("field1" -> "Upper(val1)", "field2" -> "Upper(val2)")))
r.hmget("hash2", "field1", "field2") should be(Some(Map("field1" -> "VAL1", "field2" -> "VAL2")))
}
}

it("should parse string as a bytearray with an implicit parser") {
Expand Down
8 changes: 5 additions & 3 deletions src/test/scala/com/redis/api/BaseApiSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,11 @@ trait BaseApiSpec extends AnyFunSpec
r.lrange("skey", 0, 10).get should equal(List(Some("1"), Some("3"), Some("10"), Some("30")))

// Long serialization : return Long
implicit val parseLong = Parse[Long](new String(_).toLong)
r.sortNStore[Long]("alltest", storeAt = "skey").getOrElse(-1) should equal(4)
r.lrange("skey", 0, 10).get should equal(List(Some(1), Some(3), Some(10), Some(30)))
{
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

implicit val parseLong: Parse[Long] = Parse[Long](new String(_).toLong)
r.sortNStore[Long]("alltest", storeAt = "skey").getOrElse(-1) should equal(4)
r.lrange("skey", 0, 10).get should equal(List(Some(1), Some(3), Some(10), Some(30)))
}
}
}
}
Expand Down
8 changes: 5 additions & 3 deletions src/test/scala/com/redis/cluster/CommonRedisClusterSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ import org.scalatest.matchers.should.Matchers
// todo: remove, test every API separately
@deprecated trait CommonRedisClusterSpec extends AnyFunSpec with Matchers with IntClusterSpec {

override lazy val r = rProvider()

def rProvider(): AutoCloseable with RedisClusterOps with WithHashRing[IdentifiableRedisClientPool]
type Provider = AutoCloseable with RedisClusterOps with WithHashRing[IdentifiableRedisClientPool]
with BaseApi with HashApi with ListApi with NodeApi with SetApi with SortedSetApi with StringApi
with EvalApi

override lazy val r: Provider = rProvider()

def rProvider(): Provider

describe("cluster operations") {
shouldSet()
shouldGetKeysFromProperNodes()
Expand Down