Skip to content

Commit

Permalink
feat: api tests for CR pipeline (#9)
Browse files Browse the repository at this point in the history
* feat: add base postman collection for tests

* fix: postman collection

* feat: postman collection for api tests

* feat: add api tests for CR pipeline

* feat: add api tests
  • Loading branch information
pietro-tota authored Oct 7, 2024
1 parent 105cd80 commit 9480895
Show file tree
Hide file tree
Showing 4 changed files with 449 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .devops/azure-templates/api-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
parameters:
# Required
- name: "ENV_FILE"
type: string
- name: "API_TEST_FILE"
type: string
- name: "TEST_FILE_PREFIX"
type: string
- name: 'TEST_DISPLAY_NAME'
type: string
steps:
- script: |
yarn global add newman
displayName: 'Newman installation'
- script: |
newman run ${{ parameters.API_TEST_FILE }} -e ${{ parameters.ENV_FILE }} --ignore-redirects --reporters cli,junit --reporter-junit-export Results/${{ parameters.TEST_FILE_PREFIX }}-api-TEST.xml
displayName: ${{ parameters.TEST_DISPLAY_NAME }}
- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: '**/${{ parameters.TEST_FILE_PREFIX }}-api-TEST.xml'
searchFolder: '$(System.DefaultWorkingDirectory)'
20 changes: 20 additions & 0 deletions .devops/code-review-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,23 @@ stages:
displayName: 'Publish Code Coverage on Azure Devops'


- stage: IntegrationTest
dependsOn: [ ]
jobs:
- job: make_integration_test
steps:
- script: cp .env.example .env
displayName: 'Setup env for localhost'
- script: docker compose up -d
displayName: 'Run app with docker compose'
- script: |
timeout 180 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:8080/actuator/health/liveness)" != "200" ]]; do sleep 5; done' || exit 1
displayName: 'Health check'
- template: azure-templates/api-tests.yml
parameters:
TEST_DISPLAY_NAME: "User stats api tests"
ENV_FILE: "api-tests/localhost.postman_environment.json"
API_TEST_FILE: "api-tests/user_stats_tests.postman_collection.json"
TEST_FILE_PREFIX: "wallet-api-test-cards"


51 changes: 51 additions & 0 deletions api-tests/localhost.postman_environment.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"id": "5885a323-53a9-4090-b64d-758417ddc21c",
"name": "user stats [LOCAL]",
"values": [
{
"key": "HOSTNAME",
"value": "http://localhost:8080",
"type": "default",
"enabled": true
},
{
"key": "BASE_PATH",
"value": "",
"type": "default",
"enabled": true
},
{
"key": "USER_ID",
"value": "00000000-0000-0000-0000-000000000000",
"type": "default",
"enabled": true
},
{
"key": "GUEST_METHOD_LAST_USAGE_DATE",
"value": "2000-01-01T12:00:00.123Z",
"type": "any",
"enabled": true
},
{
"key": "WALLET_LAST_USAGE_DATE",
"value": "2000-01-02T12:00:00.123Z",
"type": "default",
"enabled": true
},
{
"key": "WALLET_ID",
"value": "00000000-0000-0000-0000-000000000001",
"type": "default",
"enabled": true
},
{
"key": "PAYMENT_METHOD_ID",
"value": "00000000-0000-0000-0000-000000000002",
"type": "default",
"enabled": true
}
],
"_postman_variable_scope": "environment",
"_postman_exported_at": "2024-10-07T10:53:52.414Z",
"_postman_exported_using": "Postman/11.15.0"
}
Loading

0 comments on commit 9480895

Please sign in to comment.