forked from usebruno/bruno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(usebruno#2079): test cases to catch getEnvName() error in the future
- Loading branch information
1 parent
7bbc472
commit d027d90
Showing
3 changed files
with
157 additions
and
0 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
packages/bruno-tests/collection/scripting/get-env-name.bru
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
meta { | ||
name: get-env-name | ||
type: http | ||
seq: 1 | ||
} | ||
|
||
get { | ||
url: {{host}}/ping | ||
body: none | ||
auth: none | ||
} | ||
|
||
auth:awsv4 { | ||
accessKeyId: a | ||
secretAccessKey: b | ||
sessionToken: c | ||
service: d | ||
region: e | ||
profileName: f | ||
} | ||
|
||
script:pre-request { | ||
const envName = bru.getEnvName(); | ||
bru.setVar("testEnvName", envName); | ||
} | ||
|
||
tests { | ||
test("should get env name in scripts", function() { | ||
const testEnvName = bru.getVar("testEnvName"); | ||
expect(testEnvName).to.equal("Prod"); | ||
}); | ||
} | ||
|
||
docs { | ||
# API Documentation | ||
|
||
## Introduction | ||
|
||
Welcome to the API documentation for [Your API Name]. This document provides instructions on how to make requests to the API and covers available authentication methods. | ||
|
||
## Authentication | ||
|
||
Before making requests to the API, you need to authenticate your application. [Your API Name] supports the following authentication methods: | ||
|
||
### API Key | ||
|
||
To use API key authentication, include your API key in the request headers as follows: | ||
|
||
```http | ||
GET /api/endpoint | ||
Host: api.example.com | ||
Authorization: Bearer YOUR_API_KEY | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
meta { | ||
name: get-env-var | ||
type: http | ||
seq: 2 | ||
} | ||
|
||
get { | ||
url: {{host}}/ping | ||
body: none | ||
auth: none | ||
} | ||
|
||
auth:awsv4 { | ||
accessKeyId: a | ||
secretAccessKey: b | ||
sessionToken: c | ||
service: d | ||
region: e | ||
profileName: f | ||
} | ||
|
||
tests { | ||
test("should get env var in scripts", function() { | ||
const host = bru.getEnvVar("host") | ||
expect(host).to.equal("https://testbench-sanity.usebruno.com"); | ||
}); | ||
} | ||
|
||
docs { | ||
# API Documentation | ||
|
||
## Introduction | ||
|
||
Welcome to the API documentation for [Your API Name]. This document provides instructions on how to make requests to the API and covers available authentication methods. | ||
|
||
## Authentication | ||
|
||
Before making requests to the API, you need to authenticate your application. [Your API Name] supports the following authentication methods: | ||
|
||
### API Key | ||
|
||
To use API key authentication, include your API key in the request headers as follows: | ||
|
||
```http | ||
GET /api/endpoint | ||
Host: api.example.com | ||
Authorization: Bearer YOUR_API_KEY | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
meta { | ||
name: set-env-var | ||
type: http | ||
seq: 3 | ||
} | ||
|
||
get { | ||
url: {{host}}/ping | ||
body: none | ||
auth: none | ||
} | ||
|
||
auth:awsv4 { | ||
accessKeyId: a | ||
secretAccessKey: b | ||
sessionToken: c | ||
service: d | ||
region: e | ||
profileName: f | ||
} | ||
|
||
script:post-response { | ||
bru.setEnvVar("testSetEnvVar", "bruno-29653") | ||
} | ||
|
||
tests { | ||
test("should set env var in scripts", function() { | ||
const testSetEnvVar = bru.getEnvVar("testSetEnvVar") | ||
console.log(testSetEnvVar); | ||
expect(testSetEnvVar).to.equal("bruno-29653"); | ||
}); | ||
} | ||
|
||
docs { | ||
# API Documentation | ||
|
||
## Introduction | ||
|
||
Welcome to the API documentation for [Your API Name]. This document provides instructions on how to make requests to the API and covers available authentication methods. | ||
|
||
## Authentication | ||
|
||
Before making requests to the API, you need to authenticate your application. [Your API Name] supports the following authentication methods: | ||
|
||
### API Key | ||
|
||
To use API key authentication, include your API key in the request headers as follows: | ||
|
||
```http | ||
GET /api/endpoint | ||
Host: api.example.com | ||
Authorization: Bearer YOUR_API_KEY | ||
|
||
} |