diesel-story Pub Share

Diesel special values:

The current user

send::  msg ctx.set  (x7a)

expect::  (x7a is Source)

send::  msg ctx.set  (x7a)

expect::  (x7a is String)

send::  msg ctx.set  (x7a)

expect::  (x7a is String)

eName is a nice addressable name (firstName or username)

send::  msg ctx.set  (x7a)

expect::  (x7a is String)

Is this running in the cloud or a local box?

send::  msg ctx.set  (x7b)

expect::  (x7b is Boolean)

The current environment - see Environment settings

send::  msg ctx.set  (x7c)

expect::  (x7c is String)

The current server info (good in cluster applications)

send::  msg ctx.set  (x7d)

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

send::  msg ctx.set  (x7e)

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")

send::  msg ctx.echo  (x4)

expect::  (x4 is "123")

send::  msg ctx.echo  (x5)

expect::  (x5 is "123")

send::  msg ctx.echo  (x9)

expect::  (x9 is "123")

to json

send::  msg ctx.set  (x56)

expect::  (x56 is JSON)

Using dieselRealm to set

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

send::  msg ctx.echo  (x5)

expect::  (x5 is "aa")

send::  msg ctx.echo  (x5)

expect::  (x5 is "aa")

Dieselapps examples

This API creates a cart with items

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

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)

send::  msg testdiesel.bug.nohappypath  (a61:Number=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)

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)

expect::  (p76a not defined)

send::  msg test.diesel.dp2 

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

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)

send::  msg ctx.echo  (x)

send::  msg ctx.echo  (x)

send::  msg ctx.echo  (x)

send::  msg ctx.echo  (x)

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

send::  msg test.diesel.snakkSomething 

val x158=snakk.text(url:String="/"="/") val y159=test.diesel.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.set  (y164)

expect::  (y164 contains "hacking allowed")

Strict and nonstrict evaluations

send::  msg diesel.engine.nonstrict 

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

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

expect::  (a176 is undefined)

send::  msg test.diesel.strict 

send::  msg ctx.echo  (x)

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

0 $mock:: 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 902 times ( | History | Print ) this page.

You need to log in to post a comment!

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