Skip to content

Commit

Permalink
test: Add recording (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
Khaledgarbaya authored Jul 26, 2018
1 parent 4a5b87e commit f7973b3
Show file tree
Hide file tree
Showing 15 changed files with 10,698 additions and 17 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test/fixtures/
35 changes: 35 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"clean": "rimraf built",
"build": "npm run clean && tsc -p .",
"prepare": "npm run build",
"test": "npm run build && npm run test-unit && npm run test-integration && npm run test-e2e && npm run lint",
"test": "NOCK_RECORD=0 npm run build && npm run test-unit && npm run test-integration && npm run test-e2e && npm run lint",
"test-watch": "npm run test-unit -- --watch",
"test-unit": "NODE_ENV=test mocha --compilers ts-node/register --recursive test/unit/lib/ ",
"test-integration": "NODE_ENV=test mocha --require test/integration/setup.js 'test/integration/**/*.spec.js'",
Expand Down Expand Up @@ -101,6 +101,7 @@
"eslint-plugin-standard": "^3.0.1",
"mocha": "^5.2.0",
"nixt": "^0.5.0",
"nock": "^9.4.2",
"nyc": "^11.2.1",
"rewire": "^2.5.2",
"rimraf": "^2.6.2",
Expand All @@ -112,7 +113,8 @@
"tslint": "^5.7.0",
"tslint-config-standard": "^6.0.1",
"typescript": "^2.5.3",
"uuid": "^3.2.1"
"uuid": "^3.3.2",
"zlib": "^1.0.5"
},
"bin": {
"contentful-migration": "./bin/contentful-migration"
Expand Down
4 changes: 0 additions & 4 deletions test/end-to-end/assertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ module.exports = {
entriesTransform: function (id, message) {
return result => {
expect(result.code).to.eql(1);
expect(result.stderr).not.to.be.empty();
expect(result.stdout).not.to.be.empty();

const withoutAnsiCodes = stripAnsi(`${result.stdout} ${result.stderr}`);
expect(withoutAnsiCodes).to.include(id);
Expand Down Expand Up @@ -207,8 +205,6 @@ module.exports = {
},
entriesTransform: function (id) {
return result => {
expect(result.stdout).not.to.be.empty();

const withoutAnsiCodes = stripAnsi(result.stdout);
expect(withoutAnsiCodes).to.include(`Transform entries for ${id}`);
};
Expand Down
5 changes: 3 additions & 2 deletions test/end-to-end/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
const nixt = require('nixt');

const ACCESS_TOKEN = process.env.CONTENTFUL_INTEGRATION_MANAGEMENT_TOKEN;

process.env.TEST_ENVIRONMENT = 'end-to-end-tests';
const cli = () => {
return nixt()
.env('CONTENTFUL_MANAGEMENT_ACCESS_TOKEN', ACCESS_TOKEN)
.base('./bin/contentful-migration ').clone();
.base('./bin/contentful-migration ')
.clone();
};

module.exports = cli;
4 changes: 2 additions & 2 deletions test/end-to-end/content-transform.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ const _ = require('lodash');
const assert = require('./assertions');
const cli = require('./cli');
const { createDevEnvironment, deleteDevEnvironment, getEntries, makeRequest } = require('../helpers/client');
const uuid = require('uuid');
const SOURCE_TEST_SPACE = process.env.CONTENTFUL_INTEGRATION_SOURCE_SPACE;

const uuid = require('uuid');
const ENVIRONMENT_ID = uuid.v4();
const SOURCE_TEST_SPACE = process.env.CONTENTFUL_INTEGRATION_SOURCE_SPACE;

describe('apply content transformation', function () {
this.timeout(30000);
Expand Down
3 changes: 2 additions & 1 deletion test/end-to-end/content-type.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ const { expect } = require('chai');
const assert = require('./assertions');
const cli = require('./cli');
const { createDevEnvironment, deleteDevEnvironment, getDevContentType } = require('../helpers/client');
const uuid = require('uuid');

const uuid = require('uuid');
const ENVIRONMENT_ID = uuid.v4();

const SOURCE_TEST_SPACE = process.env.CONTENTFUL_INTEGRATION_SOURCE_SPACE;

describe('apply content-type migration examples', function () {
Expand Down
3 changes: 2 additions & 1 deletion test/end-to-end/derive-entry.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ const _ = require('lodash');
const assert = require('./assertions');
const cli = require('./cli');
const { createDevEnvironment, deleteDevEnvironment, getEntries, makeRequest } = require('../helpers/client');
const uuid = require('uuid');

const uuid = require('uuid');
const ENVIRONMENT_ID = uuid.v4();

const SOURCE_TEST_SPACE = process.env.CONTENTFUL_INTEGRATION_SOURCE_SPACE;

describe('apply derive entry transformation', function () {
Expand Down
3 changes: 2 additions & 1 deletion test/end-to-end/editor-interface.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ const { expect } = require('chai');
const assert = require('./assertions');
const cli = require('./cli');
const { createDevEnvironment, deleteDevEnvironment, getDevEditorInterface } = require('../helpers/client');
const uuid = require('uuid');

const uuid = require('uuid');
const ENVIRONMENT_ID = uuid.v4();

const SOURCE_TEST_SPACE = process.env.CONTENTFUL_INTEGRATION_SOURCE_SPACE;

describe('apply editor-interface migration examples', function () {
Expand Down
3 changes: 2 additions & 1 deletion test/end-to-end/fields.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ const { expect } = require('chai');
const assert = require('./assertions');
const cli = require('./cli');
const { createDevEnvironment, deleteDevEnvironment, getDevContentType } = require('../helpers/client');
const uuid = require('uuid');

const uuid = require('uuid');
const ENVIRONMENT_ID = uuid.v4();

const SOURCE_TEST_SPACE = process.env.CONTENTFUL_INTEGRATION_SOURCE_SPACE;

describe('apply field migration examples', function () {
Expand Down
3 changes: 2 additions & 1 deletion test/end-to-end/validations.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ const { expect } = require('chai');
const assert = require('./assertions');
const cli = require('./cli');
const { createDevEnvironment, deleteDevEnvironment, getDevContentType } = require('../helpers/client');
const uuid = require('uuid');

const uuid = require('uuid');
const ENVIRONMENT_ID = uuid.v4();

const SOURCE_TEST_SPACE = process.env.CONTENTFUL_INTEGRATION_SOURCE_SPACE;

describe('apply validations migration examples', function () {
Expand Down
Empty file added test/fixtures/.gitkeep
Empty file.
Loading

0 comments on commit f7973b3

Please sign in to comment.