Test CouchDB client with unicode docs.
diff --git a/tests/src/whisk/core/database/test/CouchDbRestClientTests.scala b/tests/src/whisk/core/database/test/CouchDbRestClientTests.scala
index a2fe472..75ec733 100644
--- a/tests/src/whisk/core/database/test/CouchDbRestClientTests.scala
+++ b/tests/src/whisk/core/database/test/CouchDbRestClientTests.scala
@@ -52,6 +52,8 @@
override implicit val patienceConfig = PatienceConfig(timeout = 10.seconds, interval = 0.5.seconds)
+ private def someId(prefix: String): String = s"${prefix}${Random.nextInt().abs.toInt}"
+
val config = new WhiskConfig(Map(
dbProvider -> null,
dbProtocol -> null,
@@ -61,7 +63,7 @@
dbPort -> null))
// We assume this DB does not exist.
- val dbName = s"whisk_test_db_${Random.nextInt().abs.toInt}"
+ val dbName = someId("whisk_test_db_")
val client = new ExtendedCouchDbRestClient(config.dbProtocol, config.dbHost, config.dbPort.toInt, config.dbUsername, config.dbPassword, dbName)
@@ -95,6 +97,22 @@
whenReady(f) { e => checkInstanceInfoResponse(e) }
}
+ it should "successfully read and write documents containing unicode" in {
+ val docId = someId("unicode_doc_")
+ val doc = JsObject("winter" -> JsString("❄ ☃ ❄"))
+ val f1 = client.putDoc(docId, doc)
+
+ whenReady(f1) { e1 =>
+ assert(e1.isRight)
+
+ val f2 = client.getDoc(docId)
+ whenReady(f2) { e2 =>
+ assert(e2.isRight)
+ assert(JsObject(e2.right.get.fields.filter(_._1 == "winter")) === doc)
+ }
+ }
+ }
+
ignore /* it */ should "successfully access the DB despite transient connection failures" in {
assume(config.dbProvider == "Cloudant" || config.dbProvider == "CouchDB")