db-story Pub

Testing DB messages and executors

Mongo persisted db tests

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

expect::  (payload is String)

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

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

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

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

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

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

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

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

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

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

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

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

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

You can clear a collection:

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

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

expect::  (payload is undefined)

Sim db tests

send::  msg diesel.db.inmem.clear 

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

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

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

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", id="1", document="act 1")

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

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

send::  msg diesel.db.inmem.log 

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

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

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

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

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

send::  msg diesel.db.inmem.query  (collection="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", id="John", document :JSON[Cart])

expect::  (payload is "John")

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

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

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

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

send::  msg diesel.db.memshared.query  (collection="Cart", cust="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", id="John")

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

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

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

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

send::  msg diesel.db.memshared.get  (collection="Cart", id="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")

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 555 times ( | History | Print ) this page.

You need to log in to post a comment!

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