db-story Pub

Testing DB messages and executors

Mongo persisted db tests

send::  msg diesel.db.col.upsert  (collection="Cart"="Cart", id="John"="John", document:JSON={cust:"Joh...)

expect::  (payload is String)

send::  msg diesel.db.col.get  (collection="Cart"="Cart", id="John"="John")

expect::  (payload[="cust"] is "John1")

send::  msg diesel.db.col.query  (collection="Cart"="Cart", cust="John2"="John2")

expect::  (payload[="data"] is Array)
expect::  (payload[="data"] is empty)
expect::  (payload[="total"] is 0)

send::  msg diesel.db.col.query  (collection="Cart"="Cart", cust="John1"="John1")

expect::  (payload[="data"][="0"=0][:String="cust"] is "John1")

send::  msg diesel.db.col.remove  (collection="Cart"="Cart", id="John"="John")

expect::  (payload[="cust"] is "John1")

send::  msg diesel.db.col.get  (collection="Cart"="Cart", id="John"="John")

expect::  (payload is empty)
expect::  (payload is undefined)

send::  msg diesel.db.col.getsert  (collection="Cart"="Cart", id="John"="John", default:JSON={cust:"Joh...)

send::  msg diesel.db.col.get  (collection="Cart"="Cart", id="John"="John")

expect::  (payload[="cust"] is "John")

You can clear a collection:

send::  msg diesel.db.col.clear  (collection="Cart"="Cart")

send::  msg diesel.db.col.get  (collection="Cart"="Cart", id="John"="John")

expect::  (payload is undefined)

Sim db tests

send::  msg diesel.db.inmem.clear 

send::  msg diesel.db.inmem.upsert  (collection="Account"="Account", document:JSON={cust:"Joh...)

expect::  (payload ~= ".+")

Problem: since the previous send::  msg diesel.db.inmem.upsert  (collection="Account"="Account", document:JSON={cust:"Joh...)

send::  msg diesel.db.inmem.log 

expect::  (payload ~= "(?s).Collection.")

send::  msg diesel.db.inmem.logAll 

// $expect (payload ~= "(?s).addr1.")

send::  msg diesel.db.inmem.upsert  (collection="Account"="Account", id="1"="1", document="act 1"="act 1")

send::  msg diesel.db.inmem.get  (collection="Account"="Account", id="1"="1")

expect::  (document ~= "act 1")

send::  msg diesel.db.inmem.log 

send::  msg diesel.db.inmem.get  (collection="Account"="Account", id="1"="1")

expect::  (document ~= "act 1")

send::  msg diesel.db.inmem.query  (collection="Account"="Account")

expect::  ( (sizeOf(payload) > 0))
expect::  ( ((payload as string) contains "act 1"))

send::  msg diesel.db.inmem.remove  (collection="Account"="Account", id="1"="1")

send::  msg diesel.db.inmem.query  (collection="Account"="Account")

expect::  (payload containsNot "act 1")

send::  msg diesel.db.inmem.clear 

send::  msg diesel.db.inmem.log 

expect::  (payload == "")

In-memory shared db tests

send::  msg diesel.db.memshared.upsert  (collection="Cart"="Cart", id="John"="John", document:Cart(JSON)={cust:"Joh...)

expect::  (payload is "John")

send::  msg diesel.db.memshared.get  (collection="Cart"="Cart", id="John"="John")

expect::  (payload[="cust"] is "John1")

send::  msg diesel.db.memshared.query  (collection="Cart"="Cart", cust="John2"="John2")

expect::  (payload[="data"] is Array)
expect::  (payload[="data"] is empty)
expect::  (payload[="total"] is 0)

send::  msg diesel.db.memshared.query  (collection="Cart"="Cart", cust="John1"="John1")

expect::  (payload[="data"][="0"=0][:String="cust"] is "John1")
expect::  (payload[="data"][="0"=0] is Json)

send::  msg diesel.db.memshared.remove  (collection="Cart"="Cart", id="John"="John")

expect::  (document[="cust"] is "John1")

send::  msg diesel.db.memshared.get  (collection="Cart"="Cart", id="John"="John")

expect::  (payload is empty)
expect::  (payload is undefined)

send::  msg diesel.db.memshared.getsert  (collection="Cart"="Cart", id="John"="John", default:JSON={cust:"Joh...)

send::  msg diesel.db.memshared.get  (collection="Cart"="Cart", id="John"="John")

expect::  (payload[="cust"] is "John")

send::  msg diesel.db.memshared.log 

send::  msg diesel.db.memshared.clear 

send::  msg diesel.db.memshared.query  (collection="Cart"="Cart")

expect::  (payload[="data"] is Array)
expect::  (payload[="data"] is empty)
expect::  (payload[="total"] is 0)

send::  msg diesel.db.memshared.log 


Was this useful?    

By: Razie | 2019-10-04 .. 2019-11-07 | Tags: story , dsl , noperf


Viewed 251 times ( | History | Print ) this page.

You need to log in to post a comment!

© Copyright DieselApps, 2012-2022, all rights reserved.