Skip to content

Commit

Permalink
Use localdev to run command tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jkcdarunday committed Sep 3, 2024
1 parent 6f08002 commit c7971fa
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions test/05-commands.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ const harness = path.join(Helper.root, 'test', 'fixtures', 'harness')
const minimal = path.join(Helper.root, 'test', 'fixtures', 'minimal')

class Rig {
setup = async ({ comment }) => {
this.helper = new Helper()
setup = async ({ comment, timeout }) => {
timeout(180000)
this.platformDir = path.join(Helper.root, 'pear')
const helper = new Helper({ platformDir: this.platformDir })

this.helper = helper
comment('connecting local sidecar')
await this.helper.ready()
await this.helper.shutdown()
this.helper = new Helper()
await this.helper.ready()
comment('local sidecar connected')
await helper.ready()
}

getOrCreateDumpInstance = async () => {
if (this.pearDumpInstance) return this.pearDumpInstance

const testId = Math.floor(Math.random() * 100000)
const argvStage = ['stage', '--json', 'test-' + testId, minimal]
const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true })
const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir })
await stager1.inspector.evaluate(`
__PEAR_TEST__.command(${JSON.stringify(argvStage)})
`, { returnByValue: false })
Expand All @@ -38,7 +38,7 @@ class Rig {
await stager1.until.exit

const argvRelease = ['release', '--json', 'test-' + testId, minimal]
const releaser1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true })
const releaser1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir })
await releaser1.inspector.evaluate(`
__PEAR_TEST__.command(${JSON.stringify(argvRelease)})
`, { returnByValue: false })
Expand All @@ -54,7 +54,7 @@ class Rig {

fs.writeFileSync(path.join(minimal, 'testfile.txt'), 'this is a test file')

const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true })
const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir })
await stager2.inspector.evaluate(`
__PEAR_TEST__.command(${JSON.stringify(argvStage)})
`, { returnByValue: false })
Expand Down Expand Up @@ -95,7 +95,7 @@ test('pear stage --json <channel> <absolute-path>', async function ({ plan, alik

const argv = ['stage', '--json', 'test-' + testId, minimal]

const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true })
const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir })

await running.inspector.evaluate(`
__PEAR_TEST__.command(${JSON.stringify(argv)})
Expand Down Expand Up @@ -292,7 +292,7 @@ test('pear dump pear://<key> <absolute-path>', async function ({ plan, is, teard
const targetDir = path.join(harness, `pear-dump-${testId}`)
teardown(async () => fs.promises.rm(targetDir, { recursive: true }))

const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true })
const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir })
const argv = ['dump', link, targetDir]
await running.inspector.evaluate(`
__PEAR_TEST__.command(${JSON.stringify(argv)})
Expand Down Expand Up @@ -326,7 +326,7 @@ test('pear dump pear://<key> <relative-path>', async function ({ plan, is, teard
const targetDirRelative = path.relative(harness, targetDir)
teardown(async () => fs.promises.rm(targetDir, { recursive: true }))

const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true })
const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir })
const argv = ['dump', link, targetDirRelative]
await running.inspector.evaluate(`
__PEAR_TEST__.command(${JSON.stringify(argv)})
Expand Down Expand Up @@ -360,7 +360,7 @@ test('pear dump --checkout <n> pear://<key> <relative-path>', async function ({
const targetDirRelative = path.relative(harness, targetDir)
teardown(async () => fs.promises.rm(targetDir, { recursive: true }))

const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true })
const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir })
const argv = ['dump', link, '--checkout', `${versionOld}`, targetDirRelative]
await running.inspector.evaluate(`
__PEAR_TEST__.command(${JSON.stringify(argv)})
Expand Down Expand Up @@ -394,7 +394,7 @@ test('pear dump --checkout staged pear://<key> <relative-path>', async function
const targetDirRelative = path.relative(harness, targetDir)
teardown(async () => fs.promises.rm(targetDir, { recursive: true }))

const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true })
const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir })
const argv = ['dump', link, '--checkout', 'staged', targetDirRelative]
await running.inspector.evaluate(`
__PEAR_TEST__.command(${JSON.stringify(argv)})
Expand Down Expand Up @@ -429,7 +429,7 @@ test('pear dump --checkout staged pear://<key> <relative-path>', async function
// const targetDirRelative = path.relative(harness, targetDir)
// teardown(async () => fs.promises.rm(targetDir, { recursive: true }))
//
// const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true })
// const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir })
// const argv = ['dump', link, '--checkout', 'release', targetDirRelative]
// await running.inspector.evaluate(`
// __PEAR_TEST__.command(${JSON.stringify(argv)})
Expand Down Expand Up @@ -463,7 +463,7 @@ test('pear dump --json pear://<key> <relative-path>', async function ({ plan, is
const targetDirRelative = path.relative(harness, targetDir)
teardown(async () => fs.promises.rm(targetDir, { recursive: true }))

const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true })
const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir })
const argv = ['dump', '--json', link, targetDirRelative]
await running.inspector.evaluate(`
__PEAR_TEST__.command(${JSON.stringify(argv)})
Expand Down

0 comments on commit c7971fa

Please sign in to comment.