Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/marp 1412 implement a common workflow for api testing #31

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/api.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Api testing

on:
push:
schedule:
- cron: '21 21 * * *'
workflow_dispatch:

jobs:
build:
uses: axonivy-market/github-workflows/.github/workflows/api.yml@feature/MARP-1412-Implement-a-common-workflow-for-api-testing
with:
postman_collection_location: ./open-weather-connector-test/src_test/resources/open-weather.postman_collection.json
secrets:
postman_env_content: ${{ secrets.postman_env_content }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
{
"info": {
"_postman_id": "b9dbdb78-789d-408c-b9ab-70082b18f31e",
"name": "open-weather-api-collection",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "20987298"
},
"item": [
{
"name": "Get weather data without token",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 401\", function () {",
" pm.response.to.have.status(401);",
"});",
"",
"pm.test(\"Response message indicates invalid API key\", function () {",
" pm.expect(pm.response.json().message).to.include(\"Invalid API key\");",
"});",
""
],
"type": "text/javascript",
"packages": {}
}
}
],
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{weatherUrl}}?q=London&units=metric",
"host": [
"{{weatherUrl}}"
],
"query": [
{
"key": "q",
"value": "London"
},
{
"key": "",
"value": "",
"disabled": true
},
{
"key": "units",
"value": "metric"
}
]
}
},
"response": []
},
{
"name": "Get weather data by lat and lon",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Location name should be Ho Chi Minh City\", function () {",
" var responseJSON = pm.response.json();",
" pm.expect(responseJSON.name).to.equal(\"Ho Chi Minh City\");",
"});",
"",
"pm.test(\"Location country should be based in Viet Nam\", function () {",
" var responseJSON = pm.response.json();",
" pm.expect(responseJSON.sys.country).to.equal('VN');",
"});",
""
],
"type": "text/javascript",
"packages": {}
}
}
],
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{weatherUrl}}?lat={{hcm-lat}}&lon={{hcm-lon}}&appid={{token}}",
"host": [
"{{weatherUrl}}"
],
"query": [
{
"key": "lat",
"value": "{{hcm-lat}}"
},
{
"key": "lon",
"value": "{{hcm-lon}}"
},
{
"key": "appid",
"value": "{{token}}"
}
]
}
},
"response": []
},
{
"name": "Get weather data by lat and lon Copy",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Check if there is 1 record with name 'Chelsea'\", function () {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData.some(item => item.name === 'Chelsea')).to.be.true;",
"});",
""
],
"type": "text/javascript",
"packages": {}
}
}
],
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{geoUrl}}?q=London&limit=5&appId={{token}}",
"host": [
"{{geoUrl}}"
],
"query": [
{
"key": "q",
"value": "London"
},
{
"key": "limit",
"value": "5"
},
{
"key": "appId",
"value": "{{token}}"
}
]
}
},
"response": []
}
]
}
Loading