rabbah commented on a change in pull request #3174: Change log level
dynamically (updated)
URL:
https://github.com/apache/incubator-openwhisk/pull/3174#discussion_r161586475
##########
File path: tests/src/test/scala/whisk/core/entity/test/SchemaTests.scala
##########
@@ -70,6 +69,46 @@ class SchemaTests extends FlatSpec with BeforeAndAfter with
ExecHelpers with Mat
a[DeserializationException] should be thrownBy
Privilege.serdes.read("???".toJson)
}
+ behavior of "TransactionId"
+
+ it should "serdes a transaction id without extraLogging parameter" in {
+ val txId = 4711
+ val txWithoutExtraLogging = TransactionId(txId)
+
+ // test serialization
+ val serializedTxIdWithoutParameter =
TransactionId.serdes.write(txWithoutExtraLogging)
+ serializedTxIdWithoutParameter match {
+ case JsArray(Vector(JsNumber(id), JsNumber(_))) =>
+ assert(id == txId)
+ case JsArray(Vector(JsNumber(_), JsNumber(_), JsBoolean(_))) =>
+ assert(false)
+ }
+
+ // test deserialization
+ val deserializedTxIdWithoutParameter =
TransactionId.serdes.read(serializedTxIdWithoutParameter)
+ deserializedTxIdWithoutParameter.meta.id should equal(txId)
+ deserializedTxIdWithoutParameter.meta.extraLogging should equal(false)
+ }
+
+ it should "serdes a transaction id with extraLogging parameter" in {
+ val txId = 4711
+ val txIdWithExtraLogging = TransactionId(txId, true)
+ // test serialization
+ val serializedTxIdWithParameter =
TransactionId.serdes.write(txIdWithExtraLogging)
+ serializedTxIdWithParameter match {
+ case JsArray(Vector(JsNumber(_), JsNumber(_))) =>
+ assert(false)
+ case JsArray(Vector(JsNumber(id), JsNumber(_), JsBoolean(extraLogging)))
=>
Review comment:
you could add a method to get the start time out of the tid and then this
check becomes simpler:
`serializedTxIdWithParameter shouldBe JsArray(... actual values...)`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services