diesel-story Pub

Diesel special values:

The current user

send::  msg ctx.set  (x7a=diesel[="u...)

expect::  (x7a is Source)

send::  msg ctx.set  (x7a=diesel[="u...)

expect::  (x7a is String)

send::  msg ctx.set  (x7a=diesel[="u...)

expect::  (x7a is String)

eName is a nice addressable name (firstName or username)

send::  msg ctx.set  (x7a=diesel[="u...)

expect::  (x7a is String)

Is this running in the cloud or a local box?

send::  msg ctx.set  (x7b=diesel[="i...)

expect::  (x7b is Boolean)

The current environment - see Environment settings

send::  msg ctx.set  (x7c=diesel[="e...)

expect::  (x7c is String)

The current server info (good in cluster applications)

send::  msg ctx.set  (x7d=diesel[="s...)

expect::  (x7d is JSON)
expect::  (x7d[="ip"] is defined)

send::  msg ctx.set  (x7e=diesel[="s...)

expect::  (x7e is String)
expect::  (x7e is x7d[="node"])

diesel parms and expressions

Set and access a value at the realm level (aka global values)

send::  msg diesel.realm.set  (xxx="123"="123")

send::  msg ctx.echo  (x4=diesel[="r...)

expect::  (x4 is "123")

send::  msg ctx.echo  (x5=diesel[="r...)

expect::  (x5 is "123")

send::  msg ctx.echo  (x9=diesel[="r...)

expect::  (x9 is "123")

to json

send::  msg ctx.set  (x56=(diesel[="...)

expect::  (x56 is JSON)

Using dieselRealm to set

send::  msg ctx.set  (dieselRealm.yyy="aa"="aa")

send::  msg ctx.echo  (x5=diesel[="r...)

expect::  (x5 is "aa")

send::  msg ctx.echo  (x5=dieselReal...)

expect::  (x5 is "aa")

Dieselapps examples

This API creates a cart with items

send::  msg snakk.json  (url ="http://www.dieselapps.com/dies"...="http://ww...)

expect::  (payload[="items"][="0"=0][:String="sku"] is "123")

propagating payload into scope

send::  msg test.diesel.usePayload 

expect::  (payload is [1,2,3])
expect::  (one is 1)

vals in specs are templates, evaluated later:

send::  msg testdiesel.specvals1 

expect::  (v20 is "x11")

send::  msg testdiesel.specvals2 

expect::  (v20 is "x22")

happy

send::  msg ctx.set  (a61:Number=61=61)

send::  msg testdiesel.bug.nohappypath  (a61:Number=44=44)

expect::  (a31 not defined)

Parm scopes

We do not export because it's just one:

send::  msg test.diesel.dp1 

expect::  (p36 is 36)
send::  msg ctx.set  (p16a=p39)

expect::  (p71a not defined)

This is some awkwardness based on how expect works - the value is not actually in the current context, alhtough expect finds it:

send::  msg test.diesel.dp11 

expect::  (p39 is 39)
send::  msg ctx.set  (p76a=p39)

expect::  (p76a not defined)

send::  msg test.diesel.dp2 

expect::  (p43 is 42)
send::  msg ctx.set  (p83=p43)

expect::  (p83 is 43)
expect::  (dieselScope[="p43"] is 43)
expect::  (p44 is 43)
expect::  (p45 is 43)
expect::  (p46 is 43)

send::  msg test.diesel.dp3 

expect::  (p49 is 49)
expect::  (dieselRoot[="p49"] is 49)

send::  msg test.diesel.dp4 

expect::  (dieselRealm[="p52"] is 52)
expect::  (diesel[="realm"][="props"][="p52"] is 52)
expect::  (diesel[="realm"][="props"][="p53"] is 53)
send::  msg ctx.echo  (x=dieselReal...)

send::  msg ctx.echo  (x=diesel[="r...)

send::  msg ctx.echo  (x=diesel[="r...)

send::  msg ctx.echo  (x=diesel)

send::  msg ctx.echo  (x=dieselReal...)

Return

send::  msg test.diesel.ret1 

expect::  (p59 is undefined)

send::  msg test.diesel.ret2 

expect::  (p63 is undefined)

send::  msg test.diesel.ret3 

expect::  (p67 is undefined)

Assigning values directly from messages

0 $mock:: sample.snakkSomething
   snakk.text (url="/"="/")
   . (payload=replaceAll(source=payload,pattern:String="script"="script",replacement:String="no hacking allowed"="no hacking allowed"))

val x158=snakk.text(url:String="/"="/") val y159=sample.snakkSomething()

TODO The reason this fails is that the guardian doesn't add the story domain to big domain so can't see the mock above...

send::  msg ctx.echo  (x158, y159)

expect::  (x158 contains "script")
expect::  (y159 containsNot "script")

send::  msg ctx.echo  (msg=sample.sna...)

Strict and nonstrict evaluations

send::  msg diesel.engine.nonstrict 

send::  msg ctx.set  (a174:Undefined=null)

expect::  (a174 is undefined)
send::  msg ctx.set  (a176=(a174 map ...)

expect::  (a176 is undefined)

send::  msg test.diesel.strict 

send::  msg ctx.echo  (x=payload)

expect::  ( ((payload as string) contains "Exception"))

$when:: test.diesel.strict
   diesel.try
   diesel.engine.strict
   ctx.set (a174:Undefined=null)
   ctx.set (a176=(a174 map ...)
   diesel.catch
     . (payload=exception)

send::  msg diesel.engine.nonstrict 


Was this useful?    

By: Razie | 2020-05-29 .. 2022-06-17 | Tags: story , dsl , sanity


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

You need to log in to post a comment!

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