Skip to content

Commit

Permalink
documentation for testing.inspect
Browse files Browse the repository at this point in the history
  • Loading branch information
ysugimoto committed Oct 16, 2023
1 parent 2903026 commit 8256a0e
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ We describe them following table and examples:
| testing.call_subroutine | FUNCTION | Call subroutine which is defined in main VCL |
| testing.fixed_time | FUNCTION | Use fixed time whole the test suite |
| testing.override_host | FUNCTION | Override request host with provided argument in the test case |
| testing.inspect | FUNCTION | Inspect predefined variables for any scopes |
| assert | FUNCTION | Assert provided expression should be true |
| assert.true | FUNCTION | Assert actual value should be true |
| assert.false | FUNCTION | Assert actual value should be false |
Expand Down Expand Up @@ -247,6 +248,25 @@ sub test_vcl {

----

### testing.inspect(STRING var_name)

Inspect specific variable. This function has special permission that all variable value can inspect.

```vcl
// @scope: recv
sub test_vcl {
// call vcl_recv Fastly reserved subroutine in RECV scope,
// will call error statement in this subroutine.
testing.call_subroutine("vcl_recv");
// Typically obj.status could not access in recv scope,
// but can inspect via this function.
assert.equal(testing.inspect("obj.status"), 400);
}
```

----

### assert(ANY expr [, STRING message])

Assert provided expression should be truthy.
Expand Down

0 comments on commit 8256a0e

Please sign in to comment.