Skip to content

Commit e0eae0c

Browse files
committed
try adding a waitUntil to check if file content updated
1 parent fa8c103 commit e0eae0c

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

packages/core/src/test/credentials/auth.test.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { UserCredentialsUtils } from '../../shared/credentials/userCredentialsUt
1919
import { getCredentialsFilename } from '../../auth/credentials/sharedCredentialsFile'
2020
import { Connection, isIamConnection, isSsoConnection, scopesSsoAccountAccess } from '../../auth/connection'
2121
import { AuthNode, createDeleteConnectionButton, promptForConnection } from '../../auth/utils'
22+
import { waitUntil } from '../../shared'
2223

2324
const ssoProfile = createSsoProfile()
2425
const scopedSsoProfile = createSsoProfile({ scopes: ['foo'] })
@@ -522,12 +523,19 @@ describe('Auth', function () {
522523
secretAccessKey: initialCreds.secretKey,
523524
sessionToken: undefined,
524525
})
525-
526+
const contentBefore = await fs.readFileText(getCredentialsFilename())
526527
await fs.delete(getCredentialsFilename())
527-
console.log('file exists after delete=%O', await fs.exists(getCredentialsFilename()))
528528
const newCreds = { ...initialCreds, accessKey: 'y', secretKey: 'y' }
529529
await UserCredentialsUtils.generateCredentialsFile(newCreds)
530-
console.log('file exists after generating=%O', await fs.exists(getCredentialsFilename()))
530+
const didUpdate = await waitUntil(
531+
async () => (await fs.readFileText(getCredentialsFilename())) !== contentBefore,
532+
{
533+
timeout: 5000,
534+
truthy: true,
535+
}
536+
)
537+
538+
assert.ok(didUpdate, 'Expected the credentials file to be updated')
531539

532540
assert.deepStrictEqual(await conn.getCredentials(), {
533541
accessKeyId: newCreds.accessKey,

0 commit comments

Comments
 (0)