Skip to content

Commit

Permalink
remove ember-cli-addon-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kelly Selden committed Dec 23, 2019
1 parent eac443b commit 5441471
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 148 deletions.
69 changes: 0 additions & 69 deletions package-lock.json

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

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,8 @@
"chai-as-promised": "^7.1.1",
"chai-fs": "^2.0.0",
"chai-string": "^1.5.0",
"cpr": "^3.0.1",
"cross-env": "^6.0.0",
"ember-cli": "3.11.0-beta.1",
"ember-cli-addon-tests": "0.11.1",
"eslint": "^6.1.0",
"eslint-config-sane": "0.8.5",
"eslint-config-sane-node": "0.2.2",
Expand Down
129 changes: 52 additions & 77 deletions test/acceptance/ember-addon-test.js
Original file line number Diff line number Diff line change
@@ -1,95 +1,64 @@
'use strict';

const path = require('path');
const { describe, it } = require('../helpers/mocha');
const { expect } = require('../helpers/chai');
const { AddonTestApp } = require('ember-cli-addon-tests');
const {
gitInit,
commit: _commit,
postCommit,
processIo,
buildTmp,
commit,
processBin,
fixtureCompare: _fixtureCompare
} = require('git-fixtures');
const { run } = require('git-diff-apply');
const {
assertNormalUpdate,
assertNoUnstaged
} = require('../helpers/assertions');
const { promisify } = require('util');
const cpr = promisify(require('cpr'));

const commitMessage = 'add files';

async function reset(tmpPath) {
await run('git rm -r .', { cwd: tmpPath });

await cpr('test/fixtures/app/local/my-app', tmpPath);
}

async function init(tmpPath) {
await gitInit({
cwd: tmpPath
});

await _commit({
cwd: tmpPath
});
}

async function commit(tmpPath) {
await _commit({
m: commitMessage,
cwd: tmpPath
});

await postCommit({
cwd: tmpPath
const run = require('../../src/run');
const replaceFile = require('boilerplate-update/src/replace-file');
const { EOL } = require('os');

async function mutatePackageJson(cwd, callback) {
await replaceFile(path.join(cwd, 'package.json'), file => {
let pkg = JSON.parse(file);
callback(pkg);
return JSON.stringify(pkg, null, 2).replace(/\n/g, EOL) + EOL;
});
}

describe(function() {
this.timeout(10 * 60 * 1000);

let app;

beforeEach(async function() {
app = new AddonTestApp();

await app.create('my-app', {
fixturesPath: 'test/fixtures/app/local',
skipNpm: true
});
this.timeout(3 * 60 * 1000);

await init(app.path);
let tmpPath;

// remove newer fixture files not present in older versions
await reset(app.path);

app.editPackageJSON(pkg => {
pkg.devDependencies['ember-cli-update'] = '*';
async function merge({
fixturesPath,
to = '3.11.0-beta.1',
commitMessage,
beforeMerge = () => Promise.resolve()
}) {
tmpPath = await buildTmp({
fixturesPath
});

await commit(app.path);

await app.run('npm', 'install', '--no-package-lock');
await beforeMerge();

await app.startServer({
command: 'update',
additionalArguments: [
'--to',
'3.11.0-beta.1',
return await (await processBin({
bin: 'ember',
args: [
'update',
`--to=${to}`,
'--resolve-conflicts'
],
detectServerStart() {
return true;
}
});
});
cwd: tmpPath,
commitMessage,
expect
})).promise;
}

function fixtureCompare({
actual = tmpPath,
mergeFixtures
}) {
let actual = app.path;
let expected = mergeFixtures;

_fixtureCompare({
Expand All @@ -99,22 +68,28 @@ describe(function() {
});
}

async function merge() {
return await processIo({
ps: app.server,
cwd: app.path,
commitMessage,
expect
});
}

it('works', async function() {
let {
status
} = await merge();
} = await merge({
fixturesPath: 'test/fixtures/app/local',
commitMessage: 'my-app',
async beforeMerge() {
await mutatePackageJson(tmpPath, pkg => {
pkg.devDependencies['ember-cli-update'] = '*';
});

await run('npm install --no-package-lock', { cwd: tmpPath });

await commit({
m: 'my-app',
cwd: tmpPath
});
}
});

// remove addon because it's not in the fixtures
app.editPackageJSON(pkg => {
await mutatePackageJson(tmpPath, pkg => {
delete pkg.devDependencies['ember-cli-update'];
});

Expand Down

0 comments on commit 5441471

Please sign in to comment.