Skip to content

Commit

Permalink
chore(docs): updating docs to match environment changes (#2476)
Browse files Browse the repository at this point in the history
  • Loading branch information
xoscar committed May 3, 2023
1 parent 4c13748 commit 8f0aa66
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 16 deletions.
20 changes: 14 additions & 6 deletions docs/docs/cli/running-tests.md
Expand Up @@ -198,15 +198,23 @@ We can run a test and specify that environment with this command:
tracetest test run -d path/to/test.yaml -e testenv -w
```

You can also reference an .env file which will be used to create a new environment or update an existing one. For example, if you have a .env file named local.env with this content:
```
POKEID=45
POKENAME=vileplume
You can also reference an environment resource file which will be used to create a new environment or update an existing one. For example, if you have a file named local.env with this content:
```
type: Environment
spec:
id: local.env
name: local.env
values:
- key: POKEID
value: 45
- key: POKENAME
value: vileplume
```

```
tracetest test run -d path/to/test.yaml -e path/to/local.env -w
```

If you use the .env approach, a new environment will be created in Tracetest. If it does not exist, the environment name and id will be the file name without the suffix .env. So, local.env becomes local.
If you use the environment resource approach, a new environment will be created in Tracetest.

The second approach is very useful if you are running tests from a CI pipeline.
The second approach is very useful if you are running tests from a CI pipeline.
39 changes: 30 additions & 9 deletions docs/docs/concepts/environments.md
Expand Up @@ -6,22 +6,43 @@ A common use case for tests is to assert the same behavior across multiple envir

Environments are objects containing variables that can be referenced by tests. You can use a single test and provide the information on which environment object will be used to run the test. To illustrate this, consider an app that is deployed in three stages: `dev`, `staging`, and `production`. We can execute the same test in all those environments, however, both `URL` and `credentials` change from environment to environment. To run the same test against the three deployments of the app, you can create three environments:

```dotenv
```yaml
# dev.env
URL=https://app-dev.com
API_TOKEN=dev-key
type: Environment
spec:
name: dev.env
id: dev.env
values:
- key: URL
value: https://app-dev.com
- key: API_TOKEN
value: dev-key
```

```dotenv
```yaml
# staging.env
URL=https://app-staging.com
API_TOKEN=staging-key
type: Environment
spec:
name: staging.env
id: staging.env
values:
- key: URL
value: https://app-staging.com
- key: API_TOKEN
value: staging-key
```

```dotenv
```yaml
# production.env
URL=https://app-prod.com
API_TOKEN=prod-key
type: Environment
spec:
name: production.env
id: production.env
values:
- key: URL
value: https://app-prod.com
- key: API_TOKEN
value: prod-key
```

Now consider the following test:
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/concepts/transactions.md
Expand Up @@ -57,4 +57,4 @@ Result: **FAILED**
* Step 2 (Finished)
* Step 3 (Finished)

Result: **FINISHED**
Result: **FINISHED**

0 comments on commit 8f0aa66

Please sign in to comment.