Skip to content

Commit fa599ae

Browse files
committed
fix breaking test
1 parent 67a2d6b commit fa599ae

File tree

8 files changed

+35
-39
lines changed

8 files changed

+35
-39
lines changed

packages/core/src/lambda/vue/configEditor/samInvokeBackend.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ export class SamInvokeWebview extends VueWebview {
286286
*/
287287
public async invokeLaunchConfig(config: AwsSamDebuggerConfiguration): Promise<void> {
288288
const finalConfig = finalizeConfig(
289-
resolveWorkspaceFolderVariable(undefined, config),
289+
await resolveWorkspaceFolderVariable(undefined, config),
290290
'Editor-Created Debug Config'
291291
)
292292
const targetUri = await getUriFromLaunchConfig(finalConfig)

packages/core/src/shared/icons.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { Uri, ThemeIcon, ThemeColor } from 'vscode'
1111
import { isCloud9 } from './extensionUtilities'
1212
import { memoize } from './utilities/functionUtils'
1313
import { getLogger } from './logger/logger'
14-
import fs from './fs/fs'
14+
import { existsSync } from 'fs'
1515

1616
// Animation:
1717
// https://code.visualstudio.com/api/references/icons-in-labels#animation
@@ -87,25 +87,25 @@ export function addColor(icon: IconPath, color: string | ThemeColor): IconPath {
8787
return new Icon(icon.id, icon.source, typeof color === 'string' ? new ThemeColor(color) : color)
8888
}
8989

90-
async function resolveIconId(
90+
function resolveIconId(
9191
id: IconId,
9292
shouldUseCloud9 = isCloud9(),
9393
iconsPath = globals.context.asAbsolutePath(path.join('resources', 'icons'))
94-
): Promise<IconPath> {
94+
): IconPath {
9595
const [namespace, ...rest] = id.split('-')
9696
const name = rest.join('-')
9797

9898
// This 'override' logic is to support legacy use-cases, though ideally we wouldn't need it at all
99-
const cloud9Override = shouldUseCloud9 ? await resolvePathsSync(path.join(iconsPath, 'cloud9'), id) : undefined
100-
const override = cloud9Override ?? (await resolvePathsSync(path.join(iconsPath, namespace), name))
99+
const cloud9Override = shouldUseCloud9 ? resolvePathsSync(path.join(iconsPath, 'cloud9'), id) : undefined
100+
const override = cloud9Override ?? resolvePathsSync(path.join(iconsPath, namespace), name)
101101
if (override) {
102102
getLogger().verbose(`icons: using override for "${id}"`)
103103
return override
104104
}
105105

106106
// TODO: remove when they support codicons + the contribution point
107107
if (shouldUseCloud9) {
108-
const generated = await resolvePathsSync(path.join(iconsPath, 'cloud9', 'generated'), id)
108+
const generated = resolvePathsSync(path.join(iconsPath, 'cloud9', 'generated'), id)
109109

110110
if (generated) {
111111
return generated
@@ -121,16 +121,16 @@ async function resolveIconId(
121121
return new Icon(namespace === 'vscode' ? name : id, source)
122122
}
123123

124-
async function resolvePathsSync(
124+
function resolvePathsSync(
125125
rootDir: string,
126126
target: string
127-
): Promise<{ light: Uri; dark: Uri; toString: () => string } | undefined> {
127+
): { light: Uri; dark: Uri; toString: () => string } | undefined {
128128
const filename = `${target}.svg`
129129
const darkPath = path.join(rootDir, 'dark', filename)
130130
const lightPath = path.join(rootDir, 'light', filename)
131131

132132
try {
133-
if (!isWeb() && (await fs.exists(darkPath)) && (await fs.exists(lightPath))) {
133+
if (!isWeb() && existsSync(darkPath) && existsSync(lightPath)) {
134134
return { dark: Uri.file(darkPath), light: Uri.file(lightPath), toString: () => filename }
135135
}
136136
} catch (error) {

packages/core/src/stepFunctions/commands/visualizeStateMachine/getStateMachineDefinitionFromCfnTemplate.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
import { fs } from '../../../shared'
6+
import { readFileSync } from 'fs'
77
import { getLogger, Logger } from '../../../shared/logger'
88

99
/**
@@ -12,13 +12,10 @@ import { getLogger, Logger } from '../../../shared/logger'
1212
*
1313
* @returns the escaped ASL Json definition string of the state machine construct
1414
*/
15-
export async function getStateMachineDefinitionFromCfnTemplate(
16-
uniqueIdentifier: string,
17-
templatePath: string
18-
): Promise<string> {
15+
export function getStateMachineDefinitionFromCfnTemplate(uniqueIdentifier: string, templatePath: string): string {
1916
const logger: Logger = getLogger()
2017
try {
21-
const data = await fs.readFileText(templatePath)
18+
const data = readFileSync(templatePath, 'utf-8')
2219
const jsonObj = JSON.parse(data)
2320
const resources = jsonObj?.Resources
2421
if (!resources) {

packages/core/src/test/awsService/redshift/notebook/cellStatusBarItemProvider.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,17 @@ describe('CellStatusBarItemProvider', function () {
3131
sinon.restore()
3232
})
3333

34-
it('provides "Connect" status bar item when cell has no connectionParams', () => {
34+
it('provides "Connect" status bar item when cell has no connectionParams', async () => {
3535
const cell = { notebook: { metadata: { connectionParams: undefined } } }
3636
const expectedText = '$(notebook-state-error) Connect'
37-
const result = cellStatusBarItemProvider.provideCellStatusBarItems(cell, undefined)
37+
const result = await cellStatusBarItemProvider.provideCellStatusBarItems(cell, undefined)
3838
assert(Array.isArray(result))
3939
assert.strictEqual(result.length, 1)
4040
assert.strictEqual(result[0].text, expectedText)
4141
})
4242

43-
it('provides status bar with success-icon and connection information', () => {
44-
const result = cellStatusBarItemProvider.provideCellStatusBarItems(cell, token)
43+
it('provides status bar with success-icon and connection information', async () => {
44+
const result = await cellStatusBarItemProvider.provideCellStatusBarItems(cell, token)
4545
const expectedText = '$(notebook-state-success) Connected to TestWarehouse'
4646
const expectedCommand = {
4747
command: 'aws.redshift.notebookConnectClicked',

packages/core/src/test/eventSchemas/commands/downloadSchemaItemCode.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ describe('CodeExtractor', function () {
473473
//Create a zip file that clashes with destination content
474474
zipHandler = createZipFileInTempDirectory(fileName, 'Second file content', zipName)
475475

476-
const collisionOccured = codeExtractor.checkFileCollisions(zipName, destinationDirectory)
476+
const collisionOccured = await codeExtractor.checkFileCollisions(zipName, destinationDirectory)
477477

478478
assert.strictEqual(collisionOccured, true, 'should confirm that collision occurs')
479479
assert(outputChannel.value.includes(expectedMessage), `channel missing msg: ${expectedMessage}`)
@@ -491,7 +491,7 @@ describe('CodeExtractor', function () {
491491
const fileName2 = 'test2.txt'
492492
zipHandler = createZipFileInTempDirectory(fileName2, 'Second file content', zipName)
493493

494-
const collisionOccured = codeExtractor.checkFileCollisions(zipName, destinationDirectory)
494+
const collisionOccured = await codeExtractor.checkFileCollisions(zipName, destinationDirectory)
495495
assert.strictEqual(
496496
collisionOccured,
497497
false,

packages/core/src/test/shared/icons.test.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,46 +11,46 @@ import { makeTemporaryToolkitFolder, tryRemoveFolder } from '../../shared/filesy
1111
import { fs } from '../../shared'
1212

1313
describe('getIcon', function () {
14-
it('returns a ThemeIcon for `vscode` codicons', async function () {
15-
const icon = await getIcon('vscode-gear', false)
14+
it('returns a ThemeIcon for `vscode` codicons', function () {
15+
const icon = getIcon('vscode-gear', false)
1616

1717
assert.ok(icon instanceof ThemeIcon)
1818
assert.strictEqual(icon.id, 'gear')
1919
})
2020

21-
it('returns a ThemeIcon for `aws` icons', async function () {
22-
const icon = await getIcon('aws-cdk-logo', false)
21+
it('returns a ThemeIcon for `aws` icons', function () {
22+
const icon = getIcon('aws-cdk-logo', false)
2323

2424
assert.ok(icon instanceof ThemeIcon)
2525
assert.strictEqual(icon.id, 'aws-cdk-logo')
2626
})
2727

28-
it('returns icon URIs for non-codicon icons', async function () {
29-
const icon = await getIcon('vscode-help', false)
28+
it('returns icon URIs for non-codicon icons', function () {
29+
const icon = getIcon('vscode-help', false)
3030

3131
assert.ok(!(icon instanceof ThemeIcon))
3232
assert.ok(icon.dark.path.endsWith('/resources/icons/vscode/dark/help.svg'))
3333
assert.ok(icon.light.path.endsWith('/resources/icons/vscode/light/help.svg'))
3434
})
3535

3636
it('can use specific icons for Cloud9', async function () {
37-
const icon = await getIcon('vscode-help', true)
37+
const icon = getIcon('vscode-help', true)
3838

3939
assert.ok(!(icon instanceof ThemeIcon))
4040
assert.ok(icon.dark.path.endsWith('/resources/icons/cloud9/dark/vscode-help.svg'))
4141
assert.ok(icon.light.path.endsWith('/resources/icons/cloud9/light/vscode-help.svg'))
4242
})
4343

4444
it('can use generated icons for Cloud9', async function () {
45-
const icon = await getIcon('aws-cdk-logo', true)
45+
const icon = getIcon('aws-cdk-logo', true)
4646

4747
assert.ok(!(icon instanceof ThemeIcon))
4848
assert.ok(icon.dark.path.endsWith('/resources/icons/cloud9/generated/dark/aws-cdk-logo.svg'))
4949
assert.ok(icon.light.path.endsWith('/resources/icons/cloud9/generated/light/aws-cdk-logo.svg'))
5050
})
5151

5252
it('can use codicons for Cloud9', async function () {
53-
const icon = await getIcon('vscode-gear', true)
53+
const icon = getIcon('vscode-gear', true)
5454

5555
assert.ok(!(icon instanceof ThemeIcon))
5656
assert.ok(icon.dark.path.endsWith('/resources/icons/cloud9/generated/dark/vscode-gear.svg'))
@@ -72,7 +72,7 @@ describe('getIcon', function () {
7272
await fs.writeFile(p, '<svg></svg>')
7373
}
7474

75-
const icon = await getIcon('aws-cdk-logo', false, tempDir)
75+
const icon = getIcon('aws-cdk-logo', false, tempDir)
7676

7777
assert.ok(!(icon instanceof ThemeIcon))
7878
assert.strictEqual(icon.dark.fsPath, Uri.file(paths[1]).fsPath)
@@ -90,7 +90,7 @@ describe('getIcon', function () {
9090
await fs.mkdir(path.dirname(logoPath))
9191
await fs.writeFile(logoPath, '<svg></svg>')
9292

93-
const icon = await getIcon('aws-cdk-logo', false, tempDir)
93+
const icon = getIcon('aws-cdk-logo', false, tempDir)
9494

9595
assert.ok(icon instanceof ThemeIcon)
9696
assert.strictEqual(icon.source?.fsPath, Uri.file(logoPath).fsPath)
@@ -102,17 +102,17 @@ describe('getIcon', function () {
102102

103103
describe('codicon', function () {
104104
it('inserts icon ids', async function () {
105-
const result = codicon`my icon: ${await getIcon('vscode-gear')}`
105+
const result = codicon`my icon: ${getIcon('vscode-gear')}`
106106
assert.strictEqual(result, 'my icon: $(gear)')
107107
})
108108

109109
it('skips adding icons if no icon font is available', async function () {
110-
const result = codicon`my icon: ${await getIcon('vscode-help')}`
110+
const result = codicon`my icon: ${getIcon('vscode-help')}`
111111
assert.strictEqual(result, 'my icon:')
112112
})
113113

114114
it('trims the resulting string', async function () {
115-
const result = codicon` some text ${await getIcon('vscode-help')} `
115+
const result = codicon` some text ${getIcon('vscode-help')} `
116116
assert.strictEqual(result, 'some text')
117117
})
118118
})

packages/core/src/test/shared/vscode/runCommand.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,7 @@ describe('runCommand', function () {
158158
})
159159

160160
it('nodejs EACCES (not wrapped by toolkit `PermissionsError`)', async function () {
161-
const expectedMsg =
162-
os.platform() === 'win32' ? /EPERM: operation not permitted/ : /EACCES: permission denied/
161+
const expectedMsg = 'Expected rw-, found r--.'
163162
const viewLogsDialog = getTestWindow().waitForMessage(expectedMsg)
164163

165164
await Promise.all([

packages/core/src/test/stepFunctions/commands/getStateMachineDefinitionFromCfnTemplate.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const cdkOutPath = normalize(normalize(__dirname).replace('/dist', '') + '/resou
1515
const templatePath = normalize(`${cdkOutPath}/templateJsonTester.template.json`)
1616

1717
describe('Get State Machine Definition from Cfn Template', function () {
18-
it('get the correct cfn definition for state machine with correct inputs', function () {
18+
it('get the correct cfn definition for state machine with correct inputs', async function () {
1919
let data = getCfnDefinition.getStateMachineDefinitionFromCfnTemplate(uniqueIdendifier, templatePath)
2020
data = getCfnDefinition.toUnescapedAslJsonString(data)
2121
assert.strictEqual(data, unescapedJsonString)

0 commit comments

Comments
 (0)