Skip to content

Commit

Permalink
test: clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonnalley committed Oct 18, 2023
1 parent a071ef1 commit ab8f9cd
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 41 deletions.
74 changes: 38 additions & 36 deletions test/integration/install.integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ describe('install/uninstall integration tests', () => {
const configDir = join(tmpdir(), 'plugin-plugins-tests', 'config')
const dataDir = join(tmpdir(), 'plugin-plugins-tests', 'data')

const cwd = process.cwd()

before(async () => {
try {
await Promise.all([
Expand Down Expand Up @@ -47,68 +49,68 @@ describe('install/uninstall integration tests', () => {

describe('basic', () => {
it('should return "No Plugins" if no plugins are installed', async () => {
await PluginsIndex.run([], process.cwd())
await PluginsIndex.run([], cwd)
expect(stubs.stdout.firstCall.firstArg).to.equal('No plugins installed.\n')
})

it('should install plugin', async () => {
await PluginsInstall.run(['@oclif/plugin-test-esm-1'], process.cwd())
await PluginsInstall.run(['@oclif/plugin-test-esm-1'], cwd)

const result = await PluginsIndex.run([], process.cwd())
const result = await PluginsIndex.run([], cwd)
expect(stubs.stdout.firstCall.firstArg).to.include('test-esm-1')
expect(result.some((r) => r.name === '@oclif/plugin-test-esm-1')).to.be.true
})

it('should uninstall plugin', async () => {
await PluginsUninstall.run(['@oclif/plugin-test-esm-1'], process.cwd())
await PluginsUninstall.run(['@oclif/plugin-test-esm-1'], cwd)

const result = await PluginsIndex.run([], process.cwd())
const result = await PluginsIndex.run([], cwd)
expect(stubs.stdout.firstCall.firstArg).to.equal('No plugins installed.\n')
expect(result.some((r) => r.name === '@oclif/plugin-test-esm-1')).to.be.false
})
})

describe('tagged', () => {
it('should install plugin from a tag', async () => {
await PluginsInstall.run(['@oclif/plugin-test-esm-1@latest'], process.cwd())
await PluginsInstall.run(['@oclif/plugin-test-esm-1@latest'], cwd)

const result = await PluginsIndex.run([], process.cwd())
const result = await PluginsIndex.run([], cwd)
expect(stubs.stdout.firstCall.firstArg).to.include('test-esm-1')
expect(result.some((r) => r.name === '@oclif/plugin-test-esm-1')).to.be.true
})

it('should uninstall plugin', async () => {
await PluginsUninstall.run(['@oclif/plugin-test-esm-1@latest'], process.cwd())
await PluginsUninstall.run(['@oclif/plugin-test-esm-1@latest'], cwd)

const result = await PluginsIndex.run([], process.cwd())
const result = await PluginsIndex.run([], cwd)
expect(stubs.stdout.firstCall.firstArg).to.equal('No plugins installed.\n')
expect(result.some((r) => r.name === '@oclif/plugin-test-esm-1')).to.be.false
})
})

describe('alias', () => {
it('should install aliased plugin', async () => {
await PluginsInstall.run(['aliasme'], process.cwd())
await PluginsInstall.run(['aliasme'], cwd)

const result = await PluginsIndex.run([], process.cwd())
const result = await PluginsIndex.run([], cwd)
expect(stubs.stdout.firstCall.firstArg).to.include('test-esm-1')
expect(result.some((r) => r.name === '@oclif/plugin-test-esm-1')).to.be.true
})

it('should uninstall aliased plugin', async () => {
await PluginsUninstall.run(['@oclif/plugin-test-esm-1'], process.cwd())
await PluginsUninstall.run(['@oclif/plugin-test-esm-1'], cwd)

const result = await PluginsIndex.run([], process.cwd())
const result = await PluginsIndex.run([], cwd)
expect(stubs.stdout.firstCall.firstArg).to.equal('No plugins installed.\n')
expect(result.some((r) => r.name === '@oclif/plugin-test-esm-1')).to.be.false
})
})

describe('github org/repo', () => {
it('should install plugin from github org/repo', async () => {
await PluginsInstall.run(['oclif/plugin-test-esm-1'], process.cwd())
await PluginsInstall.run(['oclif/plugin-test-esm-1'], cwd)

const result = await PluginsIndex.run([], process.cwd())
const result = await PluginsIndex.run([], cwd)
expect(stubs.stdout.firstCall.firstArg).to.include('test-esm-1')
expect(result.some((r) => r.name === '@oclif/plugin-test-esm-1')).to.be.true

Expand All @@ -118,19 +120,19 @@ describe('install/uninstall integration tests', () => {
})

it('should uninstall plugin from github', async () => {
await PluginsUninstall.run(['@oclif/plugin-test-esm-1'], process.cwd())
await PluginsUninstall.run(['@oclif/plugin-test-esm-1'], cwd)

const result = await PluginsIndex.run([], process.cwd())
const result = await PluginsIndex.run([], cwd)
expect(stubs.stdout.firstCall.firstArg).to.equal('No plugins installed.\n')
expect(result.some((r) => r.name === '@oclif/plugin-test-esm-1')).to.be.false
})
})

describe('github url', () => {
it('should install plugin from github url', async () => {
await PluginsInstall.run(['https://github.com/oclif/plugin-test-esm-1.git'], process.cwd())
await PluginsInstall.run(['https://github.com/oclif/plugin-test-esm-1.git'], cwd)

const result = await PluginsIndex.run([], process.cwd())
const result = await PluginsIndex.run([], cwd)
expect(stubs.stdout.firstCall.firstArg).to.include('test-esm-1')
expect(result.some((r) => r.name === '@oclif/plugin-test-esm-1')).to.be.true

Expand All @@ -140,19 +142,19 @@ describe('install/uninstall integration tests', () => {
})

it('should uninstall plugin from github', async () => {
await PluginsUninstall.run(['@oclif/plugin-test-esm-1'], process.cwd())
await PluginsUninstall.run(['@oclif/plugin-test-esm-1'], cwd)

const result = await PluginsIndex.run([], process.cwd())
const result = await PluginsIndex.run([], cwd)
expect(stubs.stdout.firstCall.firstArg).to.equal('No plugins installed.\n')
expect(result.some((r) => r.name === '@oclif/plugin-test-esm-1')).to.be.false
})
})

describe('github tagged url', () => {
it('should install plugin from github tagged url', async () => {
await PluginsInstall.run(['https://github.com/oclif/plugin-test-esm-1.git#0.5.4'], process.cwd())
await PluginsInstall.run(['https://github.com/oclif/plugin-test-esm-1.git#0.5.4'], cwd)

const result = await PluginsIndex.run([], process.cwd())
const result = await PluginsIndex.run([], cwd)
expect(stubs.stdout.firstCall.firstArg).to.include('test-esm-1')
expect(stubs.stdout.firstCall.firstArg).to.include('0.5.4')
expect(result.some((r) => r.name === '@oclif/plugin-test-esm-1')).to.be.true
Expand All @@ -163,27 +165,27 @@ describe('install/uninstall integration tests', () => {
})

it('should uninstall plugin from github', async () => {
await PluginsUninstall.run(['@oclif/plugin-test-esm-1'], process.cwd())
await PluginsUninstall.run(['@oclif/plugin-test-esm-1'], cwd)

const result = await PluginsIndex.run([], process.cwd())
const result = await PluginsIndex.run([], cwd)
expect(stubs.stdout.firstCall.firstArg).to.equal('No plugins installed.\n')
expect(result.some((r) => r.name === '@oclif/plugin-test-esm-1')).to.be.false
})
})

describe('oclif.lock', () => {
it('should install plugin with oclif.lock', async () => {
await PluginsInstall.run(['@salesforce/plugin-custom-metadata'], process.cwd())
await PluginsInstall.run(['@salesforce/plugin-custom-metadata'], cwd)

const result = await PluginsIndex.run([], process.cwd())
const result = await PluginsIndex.run([], cwd)
expect(stubs.stdout.firstCall.firstArg).to.include('@salesforce/plugin-custom-metadata')
expect(result.some((r) => r.name === '@salesforce/plugin-custom-metadata')).to.be.true
})

it('should uninstall plugin with oclif.lock', async () => {
await PluginsUninstall.run(['@salesforce/plugin-custom-metadata'], process.cwd())
await PluginsUninstall.run(['@salesforce/plugin-custom-metadata'], cwd)

const result = await PluginsIndex.run([], process.cwd())
const result = await PluginsIndex.run([], cwd)
expect(stubs.stdout.firstCall.firstArg).to.equal('No plugins installed.\n')
expect(result.some((r) => r.name === '@salesforce/plugin-custom-metadata')).to.be.false
})
Expand All @@ -192,17 +194,17 @@ describe('install/uninstall integration tests', () => {
describe('non-existent plugin', () => {
it('should not install non-existent plugin', async () => {
try {
await PluginsInstall.run(['@oclif/DOES_NOT_EXIST'], process.cwd())
await PluginsInstall.run(['@oclif/DOES_NOT_EXIST'], cwd)
} catch {}

const result = await PluginsIndex.run([], process.cwd())
const result = await PluginsIndex.run([], cwd)
expect(stubs.stdout.firstCall.firstArg).to.equal('No plugins installed.\n')
expect(result.some((r) => r.name === '@oclif/DOES_NOT_EXIST')).to.be.false
})

it('should handle uninstalling a non-existent plugin', async () => {
try {
await PluginsUninstall.run(['@oclif/DOES_NOT_EXIST'], process.cwd())
await PluginsUninstall.run(['@oclif/DOES_NOT_EXIST'], cwd)
} catch (error) {
const err = error as CLIError
expect(err.message).to.equal('@oclif/DOES_NOT_EXIST is not installed')
Expand All @@ -212,17 +214,17 @@ describe('install/uninstall integration tests', () => {

describe('scoped plugin', () => {
it('should install scoped plugin', async () => {
await PluginsInstall.run(['test-esm-1'], process.cwd())
await PluginsInstall.run(['test-esm-1'], cwd)

const result = await PluginsIndex.run([], process.cwd())
const result = await PluginsIndex.run([], cwd)
expect(stubs.stdout.firstCall.firstArg).to.include('test-esm')
expect(result.some((r) => r.name === '@oclif/plugin-test-esm-1')).to.be.true
})

it('should uninstall scoped plugin', async () => {
await PluginsUninstall.run(['test-esm-1'], process.cwd())
await PluginsUninstall.run(['test-esm-1'], cwd)

const result = await PluginsIndex.run([], process.cwd())
const result = await PluginsIndex.run([], cwd)
expect(stubs.stdout.firstCall.firstArg).to.equal('No plugins installed.\n')
expect(result.some((r) => r.name === '@oclif/plugin-test-esm-1')).to.be.false
})
Expand Down
11 changes: 6 additions & 5 deletions test/integration/link.integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ describe('link/unlink integration tests', () => {
const dataDir = join(tmpdir(), 'plugin-plugins-tests', 'data')
const pluginDir = join(tmpdir(), 'plugin-plugins-tests', 'plugin')
const repo = 'https://github.com/oclif/plugin-test-esm-1.git'
const cwd = process.cwd()

before(async () => {
try {
Expand Down Expand Up @@ -61,22 +62,22 @@ describe('link/unlink integration tests', () => {
})

it('should return "No Plugins" if no plugins are linked', async () => {
await PluginsIndex.run([], process.cwd())
await PluginsIndex.run([], cwd)
expect(stubs.stdout.firstCall.firstArg).to.equal('No plugins installed.\n')
})

it('should link plugin', async () => {
await PluginsLink.run([pluginDir, '--no-install'], process.cwd())
await PluginsLink.run([pluginDir, '--no-install'], cwd)

const result = await PluginsIndex.run([], process.cwd())
const result = await PluginsIndex.run([], cwd)
expect(stubs.stdout.firstCall.firstArg).to.include('test-esm-1')
expect(result.some((r) => r.name === '@oclif/plugin-test-esm-1')).to.be.true
})

it('should unlink plugin', async () => {
await PluginsUninstall.run([pluginDir], process.cwd())
await PluginsUninstall.run([pluginDir], cwd)

await PluginsIndex.run([], process.cwd())
await PluginsIndex.run([], cwd)
expect(stubs.stdout.firstCall.firstArg).to.equal('No plugins installed.\n')
})
})

0 comments on commit ab8f9cd

Please sign in to comment.