db-story Pub

Testing DB messages and executors

Mongo persisted db tests

send::  msg diesel.db.col.upsert  (collection<-"Cart", key<-"John", document:JSON<-{cust:"John1"})

expect::  (payload is String)

send::  msg diesel.db.col.get  (collection<-"Cart", key<-"John")

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

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

expect::  (payload is Array)
expect::  (payload is empty)

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

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

send::  msg diesel.db.col.remove  (collection<-"Cart", key<-"John")

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

send::  msg diesel.db.col.get  (collection<-"Cart", key<-"John")

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

send::  msg diesel.db.col.getsert  (collection<-"Cart", key<-"John", default:JSON<-{cust:"John"})

send::  msg diesel.db.col.get  (collection<-"Cart", key<-"John")

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

overwriting the diesel.env

msg ctx.echo  (e<-diesel.[="env"])

expect::  (e not empty)
msg ctx.set  (diesel.env<-"testing")

msg ctx.echo  (e<-diesel.[="env"])

expect::  (e == "testing")
msg ctx.set  (diesel.env<-"local")

Context echo

msg ctx.echo  (ha<-"haha")

expect::  (ha == "haha")

Sim db tests

send::  msg diesel.db.memdb.upsert  (collection<-"Account", document<-"act x")

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

send::  msg diesel.db.memdb.log 

expect::  (payload ~= "(?s).act x.")

send::  msg diesel.db.memdb.upsert  (collection<-"Account", id<-"1", document<-"act 1")

send::  msg diesel.db.memdb.get  (collection<-"Account", id<-"1")

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

send::  msg diesel.db.memdb.log 

send::  msg diesel.db.memdb.get  (collection<-"Account", id<-"1")

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

send::  msg diesel.db.memdb.clear 

send::  msg diesel.db.memdb.log 

expect::  (payload == "")

Mongo persisted db tests

send::  msg diesel.db.col.upsert  (collection<-"Cart", key<-"John", document:JSON<-{cust:"John1"})

expect::  (payload is String)

send::  msg diesel.db.col.get  (collection<-"Cart", key<-"John")

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

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

expect::  (payload is Array)
expect::  (payload is empty)

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

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

send::  msg diesel.db.col.remove  (collection<-"Cart", key<-"John")

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

send::  msg diesel.db.col.get  (collection<-"Cart", key<-"John")

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

send::  msg diesel.db.col.getsert  (collection<-"Cart", key<-"John", default:JSON<-{cust:"John"})

send::  msg diesel.db.col.get  (collection<-"Cart", key<-"John")

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


Was this useful?    

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


Viewed 72 times ( | Print ) this page.

You need to log in to post a comment!

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