Skip to content

How to test async flow #1762

Answered by ekeren
ekeren asked this question in Q&A
Mar 9, 2023 · 4 comments · 2 replies
Discussion options

You must be logged in to vote

With extern and some workarounds I was able to write a test that:

  • ✅ works on sim
  • ✅ works on tf-aws

queue/on_message.w

bring cloud;

let q = new cloud.Queue();
let c = new cloud.Counter();

// workaround for $stdlib is not defined compiler error
// had to wrap the inflight ():bool => { c.peek == 2 } inflight method with a the Predicate resource
resource Predicate {
  c: cloud.Counter;
  init(c: cloud.Counter){
    this.c = c;
  }

  inflight test(): bool{
    return this.c.peek() == 2;
  }
}

resource TestHelper {
  init(){}
  extern "helper.js" static inflight sleep(milli: num);
  
  /** 
   * test predicate every 100 miliseconds until a minute passes
  **/
  inflight assert(predicate: P…

Replies: 4 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@skinny85
Comment options

@yoav-steinberg
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by eladb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants