From 77fa0982c2e2a390bcb0c20b73e2dbae526fe53a Mon Sep 17 00:00:00 2001 From: Meike Pollakowski Date: Mon, 25 Oct 2021 17:01:08 +0200 Subject: [PATCH 1/4] update env var names --- CONTRIBUTING.md | 8 ++++---- test/end-to-end/cli-as-lib.js | 4 ++-- test/end-to-end/cli.js | 2 +- test/end-to-end/content-transform.spec.js | 2 +- test/end-to-end/content-type.spec.js | 2 +- test/end-to-end/derive-entry.spec.js | 2 +- test/end-to-end/editor-interface.spec.js | 2 +- test/end-to-end/entry-extensions.spec.js | 2 +- test/end-to-end/entry-set-tags.spec.js | 2 +- test/end-to-end/errors.spec.js | 2 +- test/end-to-end/fields.spec.js | 2 +- test/end-to-end/flags.spec.js | 2 +- test/end-to-end/payload.spec.js | 2 +- test/end-to-end/sidebar.spec.js | 2 +- test/end-to-end/tag.spec.js | 2 +- test/end-to-end/validations.spec.js | 2 +- test/helpers/client.js | 2 +- test/integration/bin/lib/contentful-client.spec.js | 4 ++-- test/integration/migration.spec.js | 2 +- test/integration/setup.js | 4 ++-- test/unit/bin/lib/config.spec.ts | 8 ++++---- 21 files changed, 30 insertions(+), 30 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b2834de70..f28690c7b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -16,12 +16,12 @@ Don't worry if this is your first time with Typescript. The language reads like In order to run integration tests, you need: -* a source space the tests are run against (`CONTENTFUL_INTEGRATION_SOURCE_SPACE`) and is called `Migrations CLI Test` -* a management token for the defined space (`CONTENTFUL_INTEGRATION_MANAGEMENT_TOKEN`) +* a source space the tests are run against (`CONTENTFUL_SPACE_ID`) and is called `Migrations CLI Test` +* a management token for the defined space (`CONTENTFUL_INTEGRATION_TEST_CMA_TOKEN`) ```sh -CONTENTFUL_INTEGRATION_SOURCE_SPACE= \ -CONTENTFUL_INTEGRATION_MANAGEMENT_TOKEN=CFPAT-xxx \ +CONTENTFUL_SPACE_ID= \ +CONTENTFUL_INTEGRATION_TEST_CMA_TOKEN=CFPAT-xxx \ npm test ``` diff --git a/test/end-to-end/cli-as-lib.js b/test/end-to-end/cli-as-lib.js index 25518de0f..afb0af855 100644 --- a/test/end-to-end/cli-as-lib.js +++ b/test/end-to-end/cli-as-lib.js @@ -2,8 +2,8 @@ const nixt = require('nixt'); -const SPACE_ID = process.env.CONTENTFUL_INTEGRATION_SOURCE_SPACE; -const ACCESS_TOKEN = process.env.CONTENTFUL_INTEGRATION_MANAGEMENT_TOKEN; +const SPACE_ID = process.env.CONTENTFUL_SPACE_ID; +const ACCESS_TOKEN = process.env.CONTENTFUL_INTEGRATION_TEST_CMA_TOKEN; const cli = () => { return nixt() .env('CONTENTFUL_SPACE_ID', SPACE_ID) diff --git a/test/end-to-end/cli.js b/test/end-to-end/cli.js index 2b83bee39..4390036b7 100644 --- a/test/end-to-end/cli.js +++ b/test/end-to-end/cli.js @@ -2,7 +2,7 @@ const nixt = require('nixt'); -const ACCESS_TOKEN = process.env.CONTENTFUL_INTEGRATION_MANAGEMENT_TOKEN; +const ACCESS_TOKEN = process.env.CONTENTFUL_INTEGRATION_TEST_CMA_TOKEN; process.env.TEST_ENVIRONMENT = 'end-to-end-tests'; const cli = () => { return nixt() diff --git a/test/end-to-end/content-transform.spec.js b/test/end-to-end/content-transform.spec.js index 8a159dca0..73127d96c 100644 --- a/test/end-to-end/content-transform.spec.js +++ b/test/end-to-end/content-transform.spec.js @@ -5,7 +5,7 @@ const _ = require('lodash'); const assert = require('./assertions'); const cli = require('./cli'); const { createDevEnvironment, deleteDevEnvironment, getEntries, makeRequest } = require('../helpers/client'); -const SOURCE_TEST_SPACE = process.env.CONTENTFUL_INTEGRATION_SOURCE_SPACE; +const SOURCE_TEST_SPACE = process.env.CONTENTFUL_SPACE_ID; const uuid = require('uuid'); const ENVIRONMENT_ID = uuid.v4(); diff --git a/test/end-to-end/content-type.spec.js b/test/end-to-end/content-type.spec.js index 90137c930..abca74a93 100644 --- a/test/end-to-end/content-type.spec.js +++ b/test/end-to-end/content-type.spec.js @@ -11,7 +11,7 @@ const { createDevEnvironment, deleteDevEnvironment, getDevContentType, getDevTag const uuid = require('uuid'); const ENVIRONMENT_ID = uuid.v4(); -const SOURCE_TEST_SPACE = process.env.CONTENTFUL_INTEGRATION_SOURCE_SPACE; +const SOURCE_TEST_SPACE = process.env.CONTENTFUL_SPACE_ID; describe('apply content-type migration examples', function () { this.timeout(30000); diff --git a/test/end-to-end/derive-entry.spec.js b/test/end-to-end/derive-entry.spec.js index f960381b1..363e4d29c 100644 --- a/test/end-to-end/derive-entry.spec.js +++ b/test/end-to-end/derive-entry.spec.js @@ -9,7 +9,7 @@ const { createDevEnvironment, deleteDevEnvironment, getEntries, makeRequest } = const uuid = require('uuid'); const ENVIRONMENT_ID = uuid.v4(); -const SOURCE_TEST_SPACE = process.env.CONTENTFUL_INTEGRATION_SOURCE_SPACE; +const SOURCE_TEST_SPACE = process.env.CONTENTFUL_SPACE_ID; describe('apply derive entry transformation', function () { this.timeout(30000); diff --git a/test/end-to-end/editor-interface.spec.js b/test/end-to-end/editor-interface.spec.js index 29d53d1c2..96e457d08 100644 --- a/test/end-to-end/editor-interface.spec.js +++ b/test/end-to-end/editor-interface.spec.js @@ -11,7 +11,7 @@ const { createDevEnvironment, deleteDevEnvironment, getDevEditorInterface } = re const uuid = require('uuid'); const ENVIRONMENT_ID = uuid.v4(); -const SOURCE_TEST_SPACE = process.env.CONTENTFUL_INTEGRATION_SOURCE_SPACE; +const SOURCE_TEST_SPACE = process.env.CONTENTFUL_SPACE_ID; describe('apply editor-interface migration examples', function () { this.timeout(30000); diff --git a/test/end-to-end/entry-extensions.spec.js b/test/end-to-end/entry-extensions.spec.js index 6cfc27369..2d1bf2973 100644 --- a/test/end-to-end/entry-extensions.spec.js +++ b/test/end-to-end/entry-extensions.spec.js @@ -11,7 +11,7 @@ const { const uuid = require('uuid'); const ENVIRONMENT_ID = uuid.v4(); -const SOURCE_TEST_SPACE = process.env.CONTENTFUL_INTEGRATION_SOURCE_SPACE; +const SOURCE_TEST_SPACE = process.env.CONTENTFUL_SPACE_ID; describe('apply entry extension migration examples', function () { this.timeout(30000); diff --git a/test/end-to-end/entry-set-tags.spec.js b/test/end-to-end/entry-set-tags.spec.js index 84021f764..bc9cc91ff 100644 --- a/test/end-to-end/entry-set-tags.spec.js +++ b/test/end-to-end/entry-set-tags.spec.js @@ -9,7 +9,7 @@ const { createDevEnvironment, deleteDevEnvironment, makeRequest } = require('../ const uuid = require('uuid'); const ENVIRONMENT_ID = uuid.v4(); -const SOURCE_TEST_SPACE = process.env.CONTENTFUL_INTEGRATION_SOURCE_SPACE; +const SOURCE_TEST_SPACE = process.env.CONTENTFUL_SPACE_ID; describe('apply set tags transformation', function () { this.timeout(30000); diff --git a/test/end-to-end/errors.spec.js b/test/end-to-end/errors.spec.js index a0028f9c4..2a33a8f7c 100644 --- a/test/end-to-end/errors.spec.js +++ b/test/end-to-end/errors.spec.js @@ -3,7 +3,7 @@ const assert = require('./assertions'); const cli = require('./cli'); -const SOURCE_TEST_SPACE = process.env.CONTENTFUL_INTEGRATION_SOURCE_SPACE; +const SOURCE_TEST_SPACE = process.env.CONTENTFUL_SPACE_ID; describe('04-steps-errors.js', function () { it('outputs the correct errors', function (done) { diff --git a/test/end-to-end/fields.spec.js b/test/end-to-end/fields.spec.js index 9b954f90d..65eb107d2 100644 --- a/test/end-to-end/fields.spec.js +++ b/test/end-to-end/fields.spec.js @@ -11,7 +11,7 @@ const { createDevEnvironment, deleteDevEnvironment, getDevContentType } = requir const uuid = require('uuid'); const ENVIRONMENT_ID = uuid.v4(); -const SOURCE_TEST_SPACE = process.env.CONTENTFUL_INTEGRATION_SOURCE_SPACE; +const SOURCE_TEST_SPACE = process.env.CONTENTFUL_SPACE_ID; describe('apply field migration examples', function () { this.timeout(30000); diff --git a/test/end-to-end/flags.spec.js b/test/end-to-end/flags.spec.js index 5820241be..275d2076f 100644 --- a/test/end-to-end/flags.spec.js +++ b/test/end-to-end/flags.spec.js @@ -5,7 +5,7 @@ const path = require('path'); const assert = require('./assertions'); const cli = require('./cli'); -const SOURCE_TEST_SPACE = process.env.CONTENTFUL_INTEGRATION_SOURCE_SPACE; +const SOURCE_TEST_SPACE = process.env.CONTENTFUL_SPACE_ID; describe('contentful-migration CLI flags', function () { it('"--help" outputs the help message', function (done) { diff --git a/test/end-to-end/payload.spec.js b/test/end-to-end/payload.spec.js index f9d5167ce..8aaec818b 100644 --- a/test/end-to-end/payload.spec.js +++ b/test/end-to-end/payload.spec.js @@ -3,7 +3,7 @@ const assert = require('./assertions'); const cli = require('./cli'); -const SOURCE_TEST_SPACE = process.env.CONTENTFUL_INTEGRATION_SOURCE_SPACE; +const SOURCE_TEST_SPACE = process.env.CONTENTFUL_SPACE_ID; describe('invalid payload errors', function () { it('outputs the validation errors', function (done) { diff --git a/test/end-to-end/sidebar.spec.js b/test/end-to-end/sidebar.spec.js index 827e63316..e12621505 100644 --- a/test/end-to-end/sidebar.spec.js +++ b/test/end-to-end/sidebar.spec.js @@ -8,7 +8,7 @@ const { DEFAULT_SIDEBAR_LIST } = require('../../built/lib/action/sidebarwidget') const uuid = require('uuid'); const ENVIRONMENT_ID = uuid.v4(); -const SOURCE_TEST_SPACE = process.env.CONTENTFUL_INTEGRATION_SOURCE_SPACE; +const SOURCE_TEST_SPACE = process.env.CONTENTFUL_SPACE_ID; describe('apply sidebar migration examples', function () { this.timeout(30000); diff --git a/test/end-to-end/tag.spec.js b/test/end-to-end/tag.spec.js index b950da51a..b41151f78 100644 --- a/test/end-to-end/tag.spec.js +++ b/test/end-to-end/tag.spec.js @@ -8,7 +8,7 @@ const { createDevEnvironment, deleteDevEnvironment, getDevTag } = require('../he const uuid = require('uuid'); const ENVIRONMENT_ID = uuid.v4(); -const SOURCE_TEST_SPACE = process.env.CONTENTFUL_INTEGRATION_SOURCE_SPACE; +const SOURCE_TEST_SPACE = process.env.CONTENTFUL_SPACE_ID; describe('apply tag migration examples', function () { this.timeout(30000); diff --git a/test/end-to-end/validations.spec.js b/test/end-to-end/validations.spec.js index 6863c7079..1a87f3dd4 100644 --- a/test/end-to-end/validations.spec.js +++ b/test/end-to-end/validations.spec.js @@ -17,7 +17,7 @@ const { const uuid = require('uuid'); const ENVIRONMENT_ID = uuid.v4(); -const SOURCE_TEST_SPACE = process.env.CONTENTFUL_INTEGRATION_SOURCE_SPACE; +const SOURCE_TEST_SPACE = process.env.CONTENTFUL_SPACE_ID; describe('apply validations migration examples', function () { this.timeout(30000); diff --git a/test/helpers/client.js b/test/helpers/client.js index bc4010d98..0b302c475 100644 --- a/test/helpers/client.js +++ b/test/helpers/client.js @@ -6,7 +6,7 @@ const { createManagementClient } = require('../../built/bin/lib/contentful-clien const createMakeRequest = require('../../built/bin/cli').createMakeRequest; const config = { - accessToken: process.env.CONTENTFUL_INTEGRATION_MANAGEMENT_TOKEN, + accessToken: process.env.CONTENTFUL_INTEGRATION_TEST_CMA_TOKEN, application: `contentful.migration-cli.e2e-test/${packageVersion}` }; diff --git a/test/integration/bin/lib/contentful-client.spec.js b/test/integration/bin/lib/contentful-client.spec.js index 6843baa66..412988cf8 100644 --- a/test/integration/bin/lib/contentful-client.spec.js +++ b/test/integration/bin/lib/contentful-client.spec.js @@ -11,10 +11,10 @@ const { createManagementClient } = contentfulClient; // Ensure that when both tokens are defined, we first take the integration one // This is mostly useful for local testing where both may be defined delete process.env['CONTENTFUL_MANAGEMENT_ACCESS_TOKEN']; -const SOURCE_TEST_SPACE = process.env.CONTENTFUL_INTEGRATION_SOURCE_SPACE; +const SOURCE_TEST_SPACE = process.env.CONTENTFUL_SPACE_ID; const fileConfig = { - cmaToken: process.env.CONTENTFUL_INTEGRATION_MANAGEMENT_TOKEN + cmaToken: process.env.CONTENTFUL_INTEGRATION_TEST_CMA_TOKEN }; describe('contentful-client', function () { diff --git a/test/integration/migration.spec.js b/test/integration/migration.spec.js index 12828e048..6ca6f22d4 100644 --- a/test/integration/migration.spec.js +++ b/test/integration/migration.spec.js @@ -37,7 +37,7 @@ after(recorder.after); const ENVIRONMENT_ID = 'env-integration'; -const SOURCE_TEST_SPACE = process.env.CONTENTFUL_INTEGRATION_SOURCE_SPACE; +const SOURCE_TEST_SPACE = process.env.CONTENTFUL_SPACE_ID; describe('the migration', function () { this.timeout(30000); diff --git a/test/integration/setup.js b/test/integration/setup.js index 1b97f04d6..7c0921e5b 100644 --- a/test/integration/setup.js +++ b/test/integration/setup.js @@ -1,8 +1,8 @@ 'use strict'; const requiredEnvVars = [ - 'CONTENTFUL_INTEGRATION_SOURCE_SPACE', - 'CONTENTFUL_INTEGRATION_MANAGEMENT_TOKEN' + 'CONTENTFUL_SPACE_ID', + 'CONTENTFUL_INTEGRATION_TEST_CMA_TOKEN' ]; const undefinedEnvVar = (key) => typeof process.env[key] === 'undefined'; diff --git a/test/unit/bin/lib/config.spec.ts b/test/unit/bin/lib/config.spec.ts index 1d487b446..e8c94f792 100644 --- a/test/unit/bin/lib/config.spec.ts +++ b/test/unit/bin/lib/config.spec.ts @@ -4,7 +4,7 @@ import { expect } from 'chai' import { getConfig } from '../../../../src/bin/lib/config' const fileConfig = { - cmaToken: process.env.CONTENTFUL_INTEGRATION_MANAGEMENT_TOKEN + cmaToken: process.env.CONTENTFUL_INTEGRATION_TEST_CMA_TOKEN } describe('Config', function () { @@ -14,16 +14,16 @@ describe('Config', function () { it('reads the contentfulrc.json', async function () { const config = getConfig({}) - expect(config.accessToken).to.eql(process.env.CONTENTFUL_INTEGRATION_MANAGEMENT_TOKEN) + expect(config.accessToken).to.eql(process.env.CONTENTFUL_INTEGRATION_TEST_CMA_TOKEN) }) it('prefers env config over contentfulrc.json', async function () { - const token = process.env.CONTENTFUL_INTEGRATION_MANAGEMENT_TOKEN + const token = process.env.CONTENTFUL_INTEGRATION_TEST_CMA_TOKEN process.env.CONTENTFUL_MANAGEMENT_ACCESS_TOKEN = 'schnitzel' const config = getConfig({}) expect(config.accessToken).to.eql('schnitzel') - process.env.CONTENTFUL_INTEGRATION_MANAGEMENT_TOKEN = token + process.env.CONTENTFUL_INTEGRATION_TEST_CMA_TOKEN = token }) it('prefers handed in config over env config', async function () { From 483c6c7f8eeb9ec65bd329e924d9cc0bcb8d3245 Mon Sep 17 00:00:00 2001 From: Meike Pollakowski Date: Mon, 25 Oct 2021 17:25:00 +0200 Subject: [PATCH 2/4] Update test commands --- .circleci/config.yml | 20 ++++++++++---------- package.json | 18 +++++++++--------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 00dd308ea..bebbecf2f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -20,7 +20,7 @@ jobs: - run: name: Check Delaration command: | - npm run test-typescript-declaration + npm run test:typescript-declaration test-unit: docker: - image: circleci/node:14 @@ -32,7 +32,7 @@ jobs: - run: name: Run Unit Tests command: | - npm run test-unit + npm run test:unit test-integration: docker: @@ -45,7 +45,7 @@ jobs: - run: name: Run Integration Tests command: | - npm run test-integration + npm run test:integration test-e2e: docker: @@ -58,7 +58,7 @@ jobs: - run: name: Run E2E Tests command: | - npm run test-e2e + npm run test:e2e release: docker: @@ -72,16 +72,16 @@ workflows: test-and-release: jobs: - check - - test-unit - - test-integration - - test-e2e + - test:unit + - test:integration + - test:e2e - release: context: dev-workflows-release requires: - check - - test-unit - - test-integration - - test-e2e + - test:unit + - test:integration + - test:e2e filters: branches: only: diff --git a/package.json b/package.json index 6bf557e4e..5f7a5dedf 100644 --- a/package.json +++ b/package.json @@ -26,18 +26,18 @@ "build": "npm run clean && tsc -p tsconfig.json", "build-dev": "npm run clean && tsc -p tsconfig-dev.json", "prepare": "npm run build", - "test": "NOCK_RECORD=0 npm run build && npm run test-unit && npm run test-integration && npm run test-e2e && npm run lint && npm run test-typescript-declaration", - "test-watch": "npm run test-unit -- --watch", - "test-unit": "NODE_ENV=test mocha --require test/setup-unit.js --recursive 'test/unit/**/**/*.spec.{js,ts}'", - "test-integration": "NODE_ENV=test mocha --require test/integration/setup.js 'test/integration/**/*.spec.js'", - "test-e2e": "NODE_ENV=test mocha 'test/end-to-end/**/*.spec.js'", - "test-typescript-declaration": "tsc --strict --noEmit index.d.ts", + "test": "NOCK_RECORD=0 npm run build && npm run test:unit && npm run test:integration && npm run test:e2e && npm run lint && npm run test:typescript-declaration", + "test:watch": "npm run test:unit -- --watch", + "test:unit": "NODE_ENV=test mocha --require test/setup-unit.js --recursive 'test/unit/**/**/*.spec.{js,ts}'", + "test:integration": "NODE_ENV=test mocha --require test/integration/setup.js 'test/integration/**/*.spec.js'", + "test:e2e": "NODE_ENV=test mocha 'test/end-to-end/**/*.spec.js'", + "test:typescript-declaration": "tsc --strict --noEmit index.d.ts", "lint": "eslint 'examples/**/*.js' 'test/**/*.js' 'src/**/*.js' && tslint --project tsconfig-dev.json --config tslint.json -e '**/*.js'", "semantic-release": "semantic-release", "travis-deploy-once": "travis-deploy-once", - "test-unit-debug": "NODE_ENV=test mocha debug --require test/setup-unit.js --recursive 'test/unit/**/**/*.spec.{js,ts}'", - "test-integration-debug": "NODE_ENV=test mocha debug --require test/integration/setup.js 'test/integration/**/*.spec.js'", - "test-e2e-debug": "NODE_ENV=test mocha debug 'test/end-to-end/**/*.spec.js'", + "test:unit:debug": "NODE_ENV=test mocha debug --require test/setup-unit.js --recursive 'test/unit/**/**/*.spec.{js,ts}'", + "test:integration:debug": "NODE_ENV=test mocha debug --require test/integration/setup.js 'test/integration/**/*.spec.js'", + "test:e2e:debug": "NODE_ENV=test mocha debug 'test/end-to-end/**/*.spec.js'", "cm": "git-cz" }, "files": [ From 3124b85702b17240010f7ed52d1cfc8437c6ba7d Mon Sep 17 00:00:00 2001 From: Meike Pollakowski Date: Mon, 25 Oct 2021 17:36:59 +0200 Subject: [PATCH 3/4] change space name --- CONTRIBUTING.md | 2 +- test/integration/bin/lib/contentful-client.spec.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f28690c7b..79c50281c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -16,7 +16,7 @@ Don't worry if this is your first time with Typescript. The language reads like In order to run integration tests, you need: -* a source space the tests are run against (`CONTENTFUL_SPACE_ID`) and is called `Migrations CLI Test` +* a source space the tests are run against (`CONTENTFUL_SPACE_ID`) and is called `contentful-migration` * a management token for the defined space (`CONTENTFUL_INTEGRATION_TEST_CMA_TOKEN`) ```sh diff --git a/test/integration/bin/lib/contentful-client.spec.js b/test/integration/bin/lib/contentful-client.spec.js index 412988cf8..f40affe31 100644 --- a/test/integration/bin/lib/contentful-client.spec.js +++ b/test/integration/bin/lib/contentful-client.spec.js @@ -23,12 +23,13 @@ describe('contentful-client', function () { }); it('can read the space', function () { + const spaceName = 'contentful-migration'; const clientConfig = Object.assign({ application: `contentful.migration-cli/0.0.0` }, getConfig()); const client = createManagementClient(clientConfig); return client.space.get({ spaceId: SOURCE_TEST_SPACE }).then((space) => { - expect(space.name).to.eql('Migrations CLI Test'); + expect(space.name).to.eql(spaceName); }); }); From 8c7cea76286f5adeb21d0d7941141732d371a19d Mon Sep 17 00:00:00 2001 From: Meike Pollakowski Date: Mon, 25 Oct 2021 17:58:54 +0200 Subject: [PATCH 4/4] fix circleci config --- .circleci/config.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index bebbecf2f..0d0b8e780 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -72,16 +72,16 @@ workflows: test-and-release: jobs: - check - - test:unit - - test:integration - - test:e2e + - test-unit + - test-integration + - test-e2e - release: context: dev-workflows-release requires: - check - - test:unit - - test:integration - - test:e2e + - test-unit + - test-integration + - test-e2e filters: branches: only: