diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/snapshot_tests.yml similarity index 77% rename from .github/workflows/integration_tests.yml rename to .github/workflows/snapshot_tests.yml index b9c5c1e8..88200d15 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/snapshot_tests.yml @@ -1,4 +1,4 @@ -name: integration-tests +name: snapshot-tests on: push: @@ -6,7 +6,7 @@ on: pull_request: jobs: - integration-tests: + snapshot-tests: runs-on: ubuntu-latest steps: @@ -35,10 +35,5 @@ jobs: env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - run: ./scripts/run_integration_tests.sh + run: ./scripts/run_snapshot_tests.sh - - name: Test getting recommended monitors - env: - DD_API_KEY: ${{ secrets.DD_API_KEY }} - DD_APP_KEY: ${{ secrets.DD_APP_KEY }} - run: npm run test:integration diff --git a/jest.config.js b/jest.config.js index e75ba566..bfe10956 100644 --- a/jest.config.js +++ b/jest.config.js @@ -10,5 +10,5 @@ module.exports = { clearMocks: true, collectCoverageFrom: ["src/**/*.ts"], testRegex: "(src\\/).*(\\.spec\\.ts)$", - testPathIgnorePatterns: ["\\.snap$", "/node_modules/", "integration_tests/"], + testPathIgnorePatterns: ["\\.snap$", "/node_modules/", "snapshot_tests/"], }; diff --git a/jest.integration.config.js b/jest.integration.config.js index 4eff76cb..1acc8f6b 100644 --- a/jest.integration.config.js +++ b/jest.integration.config.js @@ -9,5 +9,5 @@ module.exports = { testEnvironment: "/testEnvironment.js", clearMocks: true, collectCoverageFrom: ["src/**/*.ts"], - testRegex: ["(integration_tests\\/).*(\\.spec\\.ts)$"], + testRegex: ["(snapshot_tests\\/).*(\\.spec\\.ts)$"], }; diff --git a/package.json b/package.json index dc57dc15..8caa9891 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "prebuild": "./scripts/check_layers_json.sh", "build": "tsc", "test": "jest --config jest.config.js", - "test:integration": "jest ./integration_tests --config jest.integration.config.js", + "test:integration": "jest ./snapshot_tests --config jest.integration.config.js", "test:watch": "jest --watch", "coverage": "jest --coverage", "lint": "tslint --project tsconfig.json", diff --git a/scripts/run_integration_tests.sh b/scripts/run_snapshot_tests.sh similarity index 89% rename from scripts/run_integration_tests.sh rename to scripts/run_snapshot_tests.sh index 54e83d47..1bf5f19f 100755 --- a/scripts/run_integration_tests.sh +++ b/scripts/run_snapshot_tests.sh @@ -2,13 +2,13 @@ # Usage - run commands from repo root: # To check if new changes to the plugin cause changes to any snapshots: -# ./scripts/run_integration_tests.sh +# ./scripts/run_snapshot_tests.sh # To regenerate snapshots: -# UPDATE_SNAPSHOTS=true ./scripts/run_integration_tests.sh +# UPDATE_SNAPSHOTS=true ./scripts/run_snapshot_tests.sh set -e -# To add new tests create a new yml file in the 'integration_tests' directory, append it to the SERVERLESS_CONFIGS array as well as creating a name for the +# To add new tests create a new yml file in the 'snapshot_tests' directory, append it to the SERVERLESS_CONFIGS array as well as creating a name for the # snapshots that will be compared in your test. Add those snapshot names to the TEST_SNAPSHOTS and CORRECT_SNAPSHOTS arrays. # Note: Each yml config, test, and correct snapshot file should be at the same index in their own array. e.g. All the files for the forwarder test are at index 0. # In order for this script to work correctly these arrays should have the same amount of elements. @@ -25,7 +25,7 @@ if [[ "$root_dir" =~ .*"serverless-plugin-datadog/scripts".* ]]; then exit 1 fi -integration_tests_dir="$root_dir/integration_tests" +snapshot_tests_dir="$root_dir/snapshot_tests" if [ "$UPDATE_SNAPSHOTS" = "true" ]; then echo "Overwriting snapshots in this execution" fi @@ -36,7 +36,7 @@ yarn build echo "Serverless Framework version:" serverless --version -cd $integration_tests_dir +cd $snapshot_tests_dir RAW_CFN_TEMPLATE=".serverless/cloudformation-template-update-stack.json" for ((i = 0; i < ${#SERVERLESS_CONFIGS[@]}; i++)); do echo "Running 'sls package' with ${SERVERLESS_CONFIGS[i]}" @@ -68,17 +68,17 @@ for ((i = 0; i < ${#SERVERLESS_CONFIGS[@]}; i++)); do set +e # Dont exit right away if there is a diff in snapshots cd .. - python $scripts_dir/compare_snapshots.py $integration_tests_dir/${TEST_SNAPSHOTS[i]} $integration_tests_dir/${CORRECT_SNAPSHOTS[i]} + python $scripts_dir/compare_snapshots.py $snapshot_tests_dir/${TEST_SNAPSHOTS[i]} $snapshot_tests_dir/${CORRECT_SNAPSHOTS[i]} return_code=$? set -e if [ $return_code -eq 0 ]; then echo "SUCCESS: There were no differences between the ${TEST_SNAPSHOTS[i]} and ${CORRECT_SNAPSHOTS[i]}" else echo "FAILURE: There were differences between the ${TEST_SNAPSHOTS[i]} and ${CORRECT_SNAPSHOTS[i]}. Review the diff output above." - echo "If you expected the ${TEST_SNAPSHOTS[i]} to be different generate new snapshots by running this command from a development branch on your local repository: 'UPDATE_SNAPSHOTS=true ./scripts/run_integration_tests.sh'" + echo "If you expected the ${TEST_SNAPSHOTS[i]} to be different generate new snapshots by running this command from a development branch on your local repository: 'UPDATE_SNAPSHOTS=true ./scripts/run_snapshot_tests.sh'" exit 1 fi - cd $integration_tests_dir + cd $snapshot_tests_dir echo "====================================" done exit 0 diff --git a/integration_tests/FunctionLevelLayer/file.txt b/snapshot_tests/FunctionLevelLayer/file.txt similarity index 100% rename from integration_tests/FunctionLevelLayer/file.txt rename to snapshot_tests/FunctionLevelLayer/file.txt diff --git a/integration_tests/ProviderLevelLayer/file.txt b/snapshot_tests/ProviderLevelLayer/file.txt similarity index 100% rename from integration_tests/ProviderLevelLayer/file.txt rename to snapshot_tests/ProviderLevelLayer/file.txt diff --git a/integration_tests/correct_extension_apigateway_snapshot.json b/snapshot_tests/correct_extension_apigateway_snapshot.json similarity index 100% rename from integration_tests/correct_extension_apigateway_snapshot.json rename to snapshot_tests/correct_extension_apigateway_snapshot.json diff --git a/integration_tests/correct_extension_snapshot.json b/snapshot_tests/correct_extension_snapshot.json similarity index 100% rename from integration_tests/correct_extension_snapshot.json rename to snapshot_tests/correct_extension_snapshot.json diff --git a/integration_tests/correct_forwarder_snapshot.json b/snapshot_tests/correct_forwarder_snapshot.json similarity index 100% rename from integration_tests/correct_forwarder_snapshot.json rename to snapshot_tests/correct_forwarder_snapshot.json diff --git a/integration_tests/js_handler.js b/snapshot_tests/js_handler.js similarity index 100% rename from integration_tests/js_handler.js rename to snapshot_tests/js_handler.js diff --git a/integration_tests/monitors.integration.spec.ts b/snapshot_tests/monitors.integration.spec.ts similarity index 100% rename from integration_tests/monitors.integration.spec.ts rename to snapshot_tests/monitors.integration.spec.ts diff --git a/integration_tests/offline.js b/snapshot_tests/offline.js similarity index 100% rename from integration_tests/offline.js rename to snapshot_tests/offline.js diff --git a/integration_tests/py_handler.py b/snapshot_tests/py_handler.py similarity index 100% rename from integration_tests/py_handler.py rename to snapshot_tests/py_handler.py diff --git a/integration_tests/rb_handler.rb b/snapshot_tests/rb_handler.rb similarity index 100% rename from integration_tests/rb_handler.rb rename to snapshot_tests/rb_handler.rb diff --git a/integration_tests/serverless-extension-apigateway.yml b/snapshot_tests/serverless-extension-apigateway.yml similarity index 100% rename from integration_tests/serverless-extension-apigateway.yml rename to snapshot_tests/serverless-extension-apigateway.yml diff --git a/integration_tests/serverless-extension.yml b/snapshot_tests/serverless-extension.yml similarity index 100% rename from integration_tests/serverless-extension.yml rename to snapshot_tests/serverless-extension.yml diff --git a/integration_tests/serverless-forwarder.yml b/snapshot_tests/serverless-forwarder.yml similarity index 100% rename from integration_tests/serverless-forwarder.yml rename to snapshot_tests/serverless-forwarder.yml