Skip to content

Commit

Permalink
Cleanup tests (#150)
Browse files Browse the repository at this point in the history
* remove id

* typo
  • Loading branch information
ruy-dan authored May 9, 2024
1 parent 7c4e37e commit 465ee54
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 36 deletions.
4 changes: 2 additions & 2 deletions test/01-smoke.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ test('smoke', async function ({ ok, is, plan, comment, teardown }) {
const id = Math.floor(Math.random() * 10000)

comment('staging')
const staging = stager.stage({ id: Math.floor(Math.random() * 10000), channel: `test-${id}`, name: `test-${id}`, dir, dryRun: false, bare: true })
const staging = stager.stage({ channel: `test-${id}`, name: `test-${id}`, dir, dryRun: false, bare: true })
const final = await Helper.pick(staging, { tag: 'final' })
ok(final.success, 'stage succeeded')

comment('seeding')
const seeder = new Helper()
teardown(async () => seeder.shutdown())
await seeder.ready()
const seeding = seeder.seed({ id: Math.floor(Math.random() * 10000), channel: `test-${id}`, name: `test-${id}`, dir, key: null, clientArgv: [] })
const seeding = seeder.seed({ channel: `test-${id}`, name: `test-${id}`, dir, key: null, clientArgv: [] })
const until = await Helper.pick(seeding, [{ tag: 'key' }, { tag: 'announced' }])

const key = await until.key
Expand Down
12 changes: 6 additions & 6 deletions test/03-teardown.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ test('teardown', async function ({ is, ok, plan, comment, teardown, timeout }) {
const id = Math.floor(Math.random() * 10000)

comment('staging')
const stage = stager.stage({ id: Math.floor(Math.random() * 10000), channel: `test-${id}`, name: `test-${id}`, dir, dryRun: false, bare: true })
const stage = stager.stage({ channel: `test-${id}`, name: `test-${id}`, dir, dryRun: false, bare: true })
const final = await Helper.pick(stage, { tag: 'final' })
ok(final.success, 'stage succeeded')

comment('seeding')
const seeder = new Helper()
teardown(() => seeder.shutdown())
await seeder.ready()
const seed = seeder.seed({ id: Math.floor(Math.random() * 10000), channel: `test-${id}`, name: `test-${id}`, dir })
const seed = seeder.seed({ channel: `test-${id}`, name: `test-${id}`, dir })
const until = await Helper.pick(seed, [{ tag: 'key' }, { tag: 'announced' }])
const key = await until.key
const announced = await until.announced
Expand Down Expand Up @@ -63,15 +63,15 @@ test('teardown during teardown', async function ({ is, ok, plan, comment, teardo
const id = Math.floor(Math.random() * 10000)

comment('staging')
const stage = stager.stage({ id: Math.floor(Math.random() * 10000), channel: `test-${id}`, name: `test-${id}`, dir, dryRun: false, bare: true })
const stage = stager.stage({ channel: `test-${id}`, name: `test-${id}`, dir, dryRun: false, bare: true })
const final = await Helper.pick(stage, { tag: 'final' })
ok(final.success, 'stage succeeded')

comment('seeding')
const seeder = new Helper()
teardown(() => seeder.shutdown())
await seeder.ready()
const seed = seeder.seed({ id: Math.floor(Math.random() * 10000), channel: `test-${id}`, name: `test-${id}`, dir })
const seed = seeder.seed({ channel: `test-${id}`, name: `test-${id}`, dir })
const until = await Helper.pick(seed, [{ tag: 'key' }, { tag: 'announced' }])
const key = await until.key
const announced = await until.announced
Expand Down Expand Up @@ -111,15 +111,15 @@ test('exit code', async function ({ is, ok, plan, comment, teardown }) {
const id = Math.floor(Math.random() * 10000)

comment('staging')
const stage = stager.stage({ id: Math.floor(Math.random() * 10000), channel: `test-${id}`, name: `test-${id}`, dir, dryRun: false, bare: true })
const stage = stager.stage({ channel: `test-${id}`, name: `test-${id}`, dir, dryRun: false, bare: true })
const final = await Helper.pick(stage, { tag: 'final' })
ok(final.success, 'stage succeeded')

comment('seeding')
const seeder = new Helper()
teardown(() => seeder.shutdown())
await seeder.ready()
const seed = seeder.seed({ id: Math.floor(Math.random() * 10000), channel: `test-${id}`, name: `test-${id}`, dir })
const seed = seeder.seed({ channel: `test-${id}`, name: `test-${id}`, dir })
const until = await Helper.pick(seed, [{ tag: 'key' }, { tag: 'announced' }])
const key = await until.key
const announced = await until.announced
Expand Down
52 changes: 24 additions & 28 deletions test/04-updates.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,9 @@ const fs = require('bare-fs')
const hie = require('hypercore-id-encoding')
const Localdrive = require('localdrive')

const seedOpts = (id) => ({
channel: `test-${id}`, name: `test-${id}`, key: null, dir, clientArgv: [], id: Math.floor(Math.random() * 10000)
})
const seedOpts = (id) => ({ channel: `test-${id}`, name: `test-${id}`, key: null, dir, clientArgv: [] })
const stageOpts = (id) => ({ ...seedOpts(id), dryRun: false, bare: true, ignore: [] })
const releaseOpts = (id, key) => ({
id: Math.floor(Math.random() * 10000), channel: `test-${id}`, name: `test-${id}`, key
})
const releaseOpts = (id, key) => ({ channel: `test-${id}`, name: `test-${id}`, key })
const ts = () => new Date().toISOString().replace(/[:.]/g, '-')
const dir = path.join(os.cwd(), 'fixtures', 'terminal')

Expand Down Expand Up @@ -264,15 +260,15 @@ test('Pear.updates should notify Platform stage updates (different pear instance
const appDir = path.join(tmpLocaldev, 'test', 'fixtures', 'terminal')

comment('staging app')
const appStaging = appStager.stage({ id: Math.floor(Math.random() * 10000), channel: `test-${fid}`, name: `test-${fid}`, dir: appDir, dryRun: false, bare: true })
const appStaging = appStager.stage({ channel: `test-${fid}`, name: `test-${fid}`, dir: appDir, dryRun: false, bare: true })
const appFinal = await Helper.pick(appStaging, { tag: 'final' })
ok(appFinal.success, 'stage succeeded')

comment('seeding app')
const appSeeder = new Helper({ platformDir })

await appSeeder.ready()
const appSeeding = appSeeder.seed({ id: Math.floor(Math.random() * 10000), channel: `test-${fid}`, name: `test-${fid}`, dir: appDir, key: null, clientArgv: [] })
const appSeeding = appSeeder.seed({ channel: `test-${fid}`, name: `test-${fid}`, dir: appDir, key: null, clientArgv: [] })
const untilApp = await Helper.pick(appSeeding, [{ tag: 'key' }, { tag: 'announced' }])

const appKey = await untilApp.key
Expand All @@ -284,14 +280,14 @@ test('Pear.updates should notify Platform stage updates (different pear instance
comment('staging platform A')
const stager = new Helper({ platformDir })
await stager.ready()
const staging = stager.stage({ id: Math.floor(Math.random() * 10000), channel: `test-${pid}`, name: `test-${pid}`, dir: tmpLocaldev, dryRun: false, bare: true })
const staging = stager.stage({ channel: `test-${pid}`, name: `test-${pid}`, dir: tmpLocaldev, dryRun: false, bare: true })
const final = await Helper.pick(staging, { tag: 'final' })
ok(final.success, 'stage succeeded')

comment('seeding platform A')
const seeder = new Helper({ platformDir })
await seeder.ready()
const seeding = seeder.seed({ id: Math.floor(Math.random() * 10000), channel: `test-${pid}`, name: `test-${pid}`, dir: tmpLocaldev, key: null, clientArgv: [] })
const seeding = seeder.seed({ channel: `test-${pid}`, name: `test-${pid}`, dir: tmpLocaldev, key: null, clientArgv: [] })
const until = await Helper.pick(seeding, [{ tag: 'key' }, { tag: 'announced' }])

const pearKey = await until.key
Expand Down Expand Up @@ -330,7 +326,7 @@ test('Pear.updates should notify Platform stage updates (different pear instance
comment('restaging platform A')
const stager2 = new Helper({ platformDir })
await stager2.ready()
const staging2 = stager2.stage({ id: Math.floor(Math.random() * 10000), channel: `test-${pid}`, name: `test-${pid}`, dir: tmpLocaldev, dryRun: false, bare: true })
const staging2 = stager2.stage({ channel: `test-${pid}`, name: `test-${pid}`, dir: tmpLocaldev, dryRun: false, bare: true })
const final2 = await Helper.pick(staging2, { tag: 'final' })
ok(final2.success, 'stage succeeded')

Expand Down Expand Up @@ -391,15 +387,15 @@ test('Pear.updates should notify Platform stage, Platform release updates (diffe
const appDir = path.join(tmpLocaldev, 'test', 'fixtures', 'terminal')

comment('staging app')
const appStaging = appStager.stage({ id: Math.floor(Math.random() * 10000), channel: `test-${fid}`, name: `test-${fid}`, dir: appDir, dryRun: false, bare: true })
const appStaging = appStager.stage({ channel: `test-${fid}`, name: `test-${fid}`, dir: appDir, dryRun: false, bare: true })
const appFinal = await Helper.pick(appStaging, { tag: 'final' })
ok(appFinal.success, 'stage succeeded')

comment('seeding app')
const appSeeder = new Helper({ platformDir })

await appSeeder.ready()
const appSeeding = appSeeder.seed({ id: Math.floor(Math.random() * 10000), channel: `test-${fid}`, name: `test-${fid}`, dir: appDir, key: null, clientArgv: [] })
const appSeeding = appSeeder.seed({ channel: `test-${fid}`, name: `test-${fid}`, dir: appDir, key: null, clientArgv: [] })
const untilApp = await Helper.pick(appSeeding, [{ tag: 'key' }, { tag: 'announced' }])

const appKey = await untilApp.key
Expand All @@ -411,14 +407,14 @@ test('Pear.updates should notify Platform stage, Platform release updates (diffe
comment('staging platform A')
const stager = new Helper({ platformDir })
await stager.ready()
const staging = stager.stage({ id: Math.floor(Math.random() * 10000), channel: `test-${pid}`, name: `test-${pid}`, dir: tmpLocaldev, dryRun: false, bare: true })
const staging = stager.stage({ channel: `test-${pid}`, name: `test-${pid}`, dir: tmpLocaldev, dryRun: false, bare: true })
const final = await Helper.pick(staging, { tag: 'final' })
ok(final.success, 'stage succeeded')

comment('seeding platform A')
const seeder = new Helper({ platformDir })
await seeder.ready()
const seeding = seeder.seed({ id: Math.floor(Math.random() * 10000), channel: `test-${pid}`, name: `test-${pid}`, dir: tmpLocaldev, key: null, clientArgv: [] })
const seeding = seeder.seed({ channel: `test-${pid}`, name: `test-${pid}`, dir: tmpLocaldev, key: null, clientArgv: [] })
const until = await Helper.pick(seeding, [{ tag: 'key' }, { tag: 'announced' }])

const pearKey = await until.key
Expand Down Expand Up @@ -460,7 +456,7 @@ test('Pear.updates should notify Platform stage, Platform release updates (diffe
comment('restaging platform A')
const stager2 = new Helper({ platformDir })
await stager2.ready()
const staging2 = stager2.stage({ id: Math.floor(Math.random() * 10000), channel: `test-${pid}`, name: `test-${pid}`, dir: tmpLocaldev, dryRun: false, bare: true })
const staging2 = stager2.stage({ channel: `test-${pid}`, name: `test-${pid}`, dir: tmpLocaldev, dryRun: false, bare: true })
const final2 = await Helper.pick(staging2, { tag: 'final' })
ok(final2.success, 'stage succeeded')

Expand All @@ -476,7 +472,7 @@ test('Pear.updates should notify Platform stage, Platform release updates (diffe
await releaser.ready()
teardown(async () => { await releaser.shutdown() })

const releasing = releaser.release({ id: Math.floor(Math.random() * 10000), channel: `test-${pid}`, name: `test-${pid}`, key: pearKey })
const releasing = releaser.release({ channel: `test-${pid}`, name: `test-${pid}`, key: pearKey })
await Helper.pick(releasing, { tag: 'released' })

comment('waiting for platform update notification')
Expand Down Expand Up @@ -540,14 +536,14 @@ test('Pear.updates should notify App stage updates (different pear instances)',
const appDir = path.join(tmpLocaldev, 'test', 'fixtures', 'terminal')

comment('staging app')
const appStaging = appStager.stage({ id: Math.floor(Math.random() * 10000), channel: `test-${fid}`, name: `test-${fid}`, dir: appDir, dryRun: false, bare: true })
const appStaging = appStager.stage({ channel: `test-${fid}`, name: `test-${fid}`, dir: appDir, dryRun: false, bare: true })
const appFinal = await Helper.pick(appStaging, { tag: 'final' })
ok(appFinal.success, 'stage succeeded')

comment('seeding app')
const appSeeder = new Helper({ platformDir })
await appSeeder.ready()
const appSeeding = appSeeder.seed({ id: Math.floor(Math.random() * 10000), channel: `test-${fid}`, name: `test-${fid}`, dir: appDir, key: null, clientArgv: [] })
const appSeeding = appSeeder.seed({ channel: `test-${fid}`, name: `test-${fid}`, dir: appDir, key: null, clientArgv: [] })
const untilApp = await Helper.pick(appSeeding, [{ tag: 'key' }, { tag: 'announced' }])

const appKey = await untilApp.key
Expand All @@ -559,14 +555,14 @@ test('Pear.updates should notify App stage updates (different pear instances)',
comment('staging platform A')
const stager = new Helper({ platformDir })
await stager.ready()
const staging = stager.stage({ id: Math.floor(Math.random() * 10000), channel: `test-${pid}`, name: `test-${pid}`, dir: tmpLocaldev, dryRun: false, bare: true })
const staging = stager.stage({ channel: `test-${pid}`, name: `test-${pid}`, dir: tmpLocaldev, dryRun: false, bare: true })
const final = await Helper.pick(staging, { tag: 'final' })
ok(final.success, 'stage succeeded')

comment('seeding platform A')
const seeder = new Helper({ platformDir })
await seeder.ready()
const seeding = seeder.seed({ id: Math.floor(Math.random() * 10000), channel: `test-${pid}`, name: `test-${pid}`, dir: tmpLocaldev, key: null, clientArgv: [] })
const seeding = seeder.seed({ channel: `test-${pid}`, name: `test-${pid}`, dir: tmpLocaldev, key: null, clientArgv: [] })
const until = await Helper.pick(seeding, [{ tag: 'key' }, { tag: 'announced' }])

const pearKey = await until.key
Expand Down Expand Up @@ -605,7 +601,7 @@ test('Pear.updates should notify App stage updates (different pear instances)',
comment('restaging app')
const appStager2 = new Helper({ platformDir })
await appStager2.ready()
const appStaging2 = appStager2.stage({ id: Math.floor(Math.random() * 10000), channel: `test-${fid}`, name: `test-${fid}`, dir: appDir, dryRun: false, bare: true })
const appStaging2 = appStager2.stage({ channel: `test-${fid}`, name: `test-${fid}`, dir: appDir, dryRun: false, bare: true })
const appFinal2 = await Helper.pick(appStaging2, { tag: 'final' })
ok(appFinal2.success, 'stage succeeded')

Expand Down Expand Up @@ -666,14 +662,14 @@ test('Pear.updates should notify App stage, App release updates (different pear
const appDir = path.join(tmpLocaldev, 'test', 'fixtures', 'terminal')

comment('staging app')
const appStaging = appStager.stage({ id: Math.floor(Math.random() * 10000), channel: `test-${fid}`, name: `test-${fid}`, dir: appDir, dryRun: false, bare: true })
const appStaging = appStager.stage({ channel: `test-${fid}`, name: `test-${fid}`, dir: appDir, dryRun: false, bare: true })
const appFinal = await Helper.pick(appStaging, { tag: 'final' })
ok(appFinal.success, 'stage succeeded')

comment('seeding app')
const appSeeder = new Helper({ platformDir })
await appSeeder.ready()
const appSeeding = appSeeder.seed({ id: Math.floor(Math.random() * 10000), channel: `test-${fid}`, name: `test-${fid}`, dir: appDir, key: null, clientArgv: [] })
const appSeeding = appSeeder.seed({ channel: `test-${fid}`, name: `test-${fid}`, dir: appDir, key: null, clientArgv: [] })
const untilApp = await Helper.pick(appSeeding, [{ tag: 'key' }, { tag: 'announced' }])

const appKey = await untilApp.key
Expand All @@ -685,14 +681,14 @@ test('Pear.updates should notify App stage, App release updates (different pear
comment('staging platform A')
const stager = new Helper({ platformDir })
await stager.ready()
const staging = stager.stage({ id: Math.floor(Math.random() * 10000), channel: `test-${pid}`, name: `test-${pid}`, dir: tmpLocaldev, dryRun: false, bare: true })
const staging = stager.stage({ channel: `test-${pid}`, name: `test-${pid}`, dir: tmpLocaldev, dryRun: false, bare: true })
const final = await Helper.pick(staging, { tag: 'final' })
ok(final.success, 'stage succeeded')

comment('seeding platform A')
const seeder = new Helper({ platformDir })
await seeder.ready()
const seeding = seeder.seed({ id: Math.floor(Math.random() * 10000), channel: `test-${pid}`, name: `test-${pid}`, dir: tmpLocaldev, key: null, clientArgv: [] })
const seeding = seeder.seed({ channel: `test-${pid}`, name: `test-${pid}`, dir: tmpLocaldev, key: null, clientArgv: [] })
const until = await Helper.pick(seeding, [{ tag: 'key' }, { tag: 'announced' }])

const pearKey = await until.key
Expand Down Expand Up @@ -734,7 +730,7 @@ test('Pear.updates should notify App stage, App release updates (different pear
comment('restaging app')
const appStager2 = new Helper({ platformDir })
await appStager2.ready()
const appStaging2 = appStager2.stage({ id: Math.floor(Math.random() * 10000), channel: `test-${fid}`, name: `test-${fid}`, dir: appDir, dryRun: false, bare: true })
const appStaging2 = appStager2.stage({ channel: `test-${fid}`, name: `test-${fid}`, dir: appDir, dryRun: false, bare: true })
const appFinal2 = await Helper.pick(appStaging2, { tag: 'final' })
ok(appFinal2.success, 'stage succeeded')

Expand All @@ -750,7 +746,7 @@ test('Pear.updates should notify App stage, App release updates (different pear
await releaser.ready()
teardown(async () => { await releaser.shutdown() })

const releasing = releaser.release({ id: Math.floor(Math.random() * 10000), channel: `test-${pid}`, name: `test-${pid}`, key: appKey })
const releasing = releaser.release({ channel: `test-${pid}`, name: `test-${pid}`, key: appKey })
await Helper.pick(releasing, { tag: 'released' })

comment('waiting for app update notification')
Expand Down

0 comments on commit 465ee54

Please sign in to comment.