Skip to content

Commit 820f7cb

Browse files
committed
fixed async/await test case fallout from eslint changes
Signed-off-by: Jeromy Cannon <[email protected]>
1 parent 2490ba2 commit 820f7cb

File tree

2 files changed

+38
-39
lines changed

2 files changed

+38
-39
lines changed

Diff for: test/unit/core/platform_installer.test.mjs

+14-14
Original file line numberDiff line numberDiff line change
@@ -36,61 +36,61 @@ describe('PackageInstaller', () => {
3636
const installer = new PlatformInstaller(testLogger, k8, configManager, accountManager)
3737

3838
describe('validatePlatformReleaseDir', () => {
39-
it('should fail for missing path', async () => {
39+
it('should fail for missing path', () => {
4040
expect.assertions(1)
41-
await expect(installer.validatePlatformReleaseDir('')).rejects.toThrow(MissingArgumentError)
41+
expect(() => { installer.validatePlatformReleaseDir('') }).toThrow(MissingArgumentError)
4242
})
4343

44-
it('should fail for invalid path', async () => {
44+
it('should fail for invalid path', () => {
4545
expect.assertions(1)
46-
await expect(installer.validatePlatformReleaseDir('/INVALID')).rejects.toThrow(IllegalArgumentError)
46+
expect(() => { installer.validatePlatformReleaseDir('/INVALID') }).toThrow(IllegalArgumentError)
4747
})
4848

49-
it('should fail if directory does not have data/apps directory', async () => {
49+
it('should fail if directory does not have data/apps directory', () => {
5050
expect.assertions(1)
5151

5252
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'installer-'))
5353
fs.mkdirSync(`${tmpDir}/${core.constants.HEDERA_DATA_LIB_DIR}`, { recursive: true })
54-
await expect(installer.validatePlatformReleaseDir(tmpDir)).rejects.toThrow(IllegalArgumentError)
54+
expect(() => { installer.validatePlatformReleaseDir(tmpDir) }).toThrow(IllegalArgumentError)
5555
fs.rmSync(tmpDir, { recursive: true })
5656
})
5757

58-
it('should fail if directory does not have data/libs directory', async () => {
58+
it('should fail if directory does not have data/libs directory', () => {
5959
expect.assertions(1)
6060

6161
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'installer-'))
6262
fs.mkdirSync(`${tmpDir}/${core.constants.HEDERA_DATA_APPS_DIR}`, { recursive: true })
63-
await expect(installer.validatePlatformReleaseDir(tmpDir)).rejects.toThrow(IllegalArgumentError)
63+
expect(() => { installer.validatePlatformReleaseDir(tmpDir) }).toThrow(IllegalArgumentError)
6464
fs.rmSync(tmpDir, { recursive: true })
6565
})
6666

67-
it('should fail if directory does not have data/app directory is empty', async () => {
67+
it('should fail if directory does not have data/app directory is empty', () => {
6868
expect.assertions(1)
6969

7070
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'installer-'))
7171
fs.mkdirSync(`${tmpDir}/${core.constants.HEDERA_DATA_APPS_DIR}`, { recursive: true })
7272
fs.mkdirSync(`${tmpDir}/${core.constants.HEDERA_DATA_LIB_DIR}`, { recursive: true })
7373
fs.writeFileSync(`${tmpDir}/${core.constants.HEDERA_DATA_LIB_DIR}/test.jar`, '')
74-
await expect(installer.validatePlatformReleaseDir()).rejects.toThrow(MissingArgumentError)
74+
expect(() => { installer.validatePlatformReleaseDir() }).toThrow(MissingArgumentError)
7575
fs.rmSync(tmpDir, { recursive: true })
7676
})
7777

78-
it('should fail if directory does not have data/apps directory is empty', async () => {
78+
it('should fail if directory does not have data/apps directory is empty', () => {
7979
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'installer-app-'))
8080
fs.mkdirSync(`${tmpDir}/${core.constants.HEDERA_DATA_APPS_DIR}`, { recursive: true })
8181
fs.writeFileSync(`${tmpDir}/${core.constants.HEDERA_DATA_APPS_DIR}/app.jar`, '')
8282
fs.mkdirSync(`${tmpDir}/${core.constants.HEDERA_DATA_LIB_DIR}`, { recursive: true })
83-
await expect(installer.validatePlatformReleaseDir()).rejects.toThrow(MissingArgumentError)
83+
expect(() => { installer.validatePlatformReleaseDir() }).toThrow(MissingArgumentError)
8484
fs.rmSync(tmpDir, { recursive: true })
8585
})
8686

87-
it('should succeed with non-empty data/apps and data/libs directory', async () => {
87+
it('should succeed with non-empty data/apps and data/libs directory', () => {
8888
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'installer-lib-'))
8989
fs.mkdirSync(`${tmpDir}/${core.constants.HEDERA_DATA_APPS_DIR}`, { recursive: true })
9090
fs.writeFileSync(`${tmpDir}/${core.constants.HEDERA_DATA_APPS_DIR}/app.jar`, '')
9191
fs.mkdirSync(`${tmpDir}/${core.constants.HEDERA_DATA_LIB_DIR}`, { recursive: true })
9292
fs.writeFileSync(`${tmpDir}/${core.constants.HEDERA_DATA_LIB_DIR}/lib-1.jar`, '')
93-
await expect(installer.validatePlatformReleaseDir()).rejects.toThrow(MissingArgumentError)
93+
expect(() => { installer.validatePlatformReleaseDir() }).toThrow(MissingArgumentError)
9494
fs.rmSync(tmpDir, { recursive: true })
9595
})
9696
})

Diff for: test/unit/core/zippy.test.mjs

+24-25
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
* limitations under the License.
1515
*
1616
*/
17-
import { describe, expect, it } from '@jest/globals'
1817
import * as core from '../../../src/core/index.mjs'
1918
import { SoloError, IllegalArgumentError, MissingArgumentError } from '../../../src/core/errors.mjs'
2019
import os from 'os'
@@ -26,72 +25,72 @@ describe('Zippy', () => {
2625
const zippy = new Zippy(testLogger)
2726

2827
describe('unzip', () => {
29-
it('should fail if source file is missing', async () => {
28+
it('should fail if source file is missing', () => {
3029
expect.assertions(1)
31-
await expect(zippy.unzip('', '')).rejects.toThrow(MissingArgumentError)
30+
expect(() => { zippy.unzip('', '') }).toThrow(MissingArgumentError)
3231
})
3332

34-
it('should fail if destination file is missing', async () => {
33+
it('should fail if destination file is missing', () => {
3534
expect.assertions(1)
36-
await expect(zippy.unzip('', '')).rejects.toThrow(MissingArgumentError)
35+
expect(() => { zippy.unzip('', '') }).toThrow(MissingArgumentError)
3736
})
3837

39-
it('should fail if source file is invalid', async () => {
38+
it('should fail if source file is invalid', () => {
4039
expect.assertions(1)
41-
await expect(zippy.unzip('/INVALID', os.tmpdir())).rejects.toThrow(IllegalArgumentError)
40+
expect(() => { zippy.unzip('/INVALID', os.tmpdir()) }).toThrow(IllegalArgumentError)
4241
})
4342

44-
it('should fail for a directory', async () => {
43+
it('should fail for a directory', () => {
4544
expect.assertions(1)
46-
await expect(zippy.unzip('test/data', os.tmpdir())).rejects.toThrow(SoloError)
45+
expect(() => { zippy.unzip('test/data', os.tmpdir()) }).toThrow(SoloError)
4746
})
4847

49-
it('should fail for a non-zip file', async () => {
48+
it('should fail for a non-zip file', () => {
5049
expect.assertions(1)
51-
await expect(zippy.unzip('test/data/test.txt', os.tmpdir())).rejects.toThrow(SoloError)
50+
expect(() => { zippy.unzip('test/data/test.txt', os.tmpdir()) }).toThrow(SoloError)
5251
})
5352

5453
it('should succeed for valid inputs', async () => {
5554
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'installer-'))
5655
const zipFile = `${tmpDir}/test.zip`
5756
const unzippedFile = `${tmpDir}/unzipped`
5857
await expect(zippy.zip('test/data/.empty', zipFile)).resolves.toBe(zipFile)
59-
await expect(zippy.unzip(zipFile, unzippedFile, true)).resolves.toBe(unzippedFile)
58+
expect(zippy.unzip(zipFile, unzippedFile, true)).toBe(unzippedFile)
6059
fs.rmSync(tmpDir, { recursive: true, force: true }) // not very safe!
6160
})
6261
})
6362

6463
describe('untar', () => {
65-
it('should fail if source file is missing', async () => {
64+
it('should fail if source file is missing', () => {
6665
expect.assertions(1)
67-
await expect(zippy.untar('', '')).rejects.toThrow(MissingArgumentError)
66+
expect(() => { zippy.untar('', '') }).toThrow(MissingArgumentError)
6867
})
6968

70-
it('should fail if destination file is missing', async () => {
69+
it('should fail if destination file is missing', () => {
7170
expect.assertions(1)
72-
await expect(zippy.untar('', '')).rejects.toThrow(MissingArgumentError)
71+
expect(() => { zippy.untar('', '') }).toThrow(MissingArgumentError)
7372
})
7473

75-
it('should fail if source file is invalid', async () => {
74+
it('should fail if source file is invalid', () => {
7675
expect.assertions(1)
77-
await expect(zippy.untar('/INVALID', os.tmpdir())).rejects.toThrow(IllegalArgumentError)
76+
expect(() => { zippy.untar('/INVALID', os.tmpdir()) }).toThrow(IllegalArgumentError)
7877
})
7978

80-
it('should fail for a directory', async () => {
79+
it('should fail for a directory', () => {
8180
expect.assertions(1)
82-
await expect(zippy.untar('test/data', os.tmpdir())).rejects.toThrow(SoloError)
81+
expect(() => { zippy.untar('test/data', os.tmpdir()) }).toThrow(SoloError)
8382
})
8483

85-
it('should fail for a non-tar file', async () => {
84+
it('should fail for a non-tar file', () => {
8685
expect.assertions(1)
87-
await expect(zippy.untar('test/data/test.txt', os.tmpdir())).rejects.toThrow(SoloError)
86+
expect(() => { zippy.untar('test/data/test.txt', os.tmpdir()) }).toThrow(SoloError)
8887
})
8988

90-
it('should succeed for valid inputs', async () => {
89+
it('should succeed for valid inputs', () => {
9190
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'installer-'))
9291
const tarFile = `${tmpDir}/test.tar.gz`
93-
await expect(zippy.tar('test/data/.empty', tarFile)).resolves.toBe(tarFile)
94-
await expect(zippy.untar(tarFile, tmpDir, true)).resolves.toBe(tmpDir)
92+
expect(zippy.tar('test/data/.empty', tarFile), 'tar file should match').toBe(tarFile)
93+
expect(zippy.untar(tarFile, tmpDir), 'tmp dir should match').toBe(tmpDir)
9594
fs.rmSync(tmpDir, { recursive: true, force: true }) // not very safe!
9695
})
9796
})

0 commit comments

Comments
 (0)