Skip to content

Commit e83c6df

Browse files
committed
fix test so it won't remove aws config
1 parent 0164d41 commit e83c6df

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

packages/core/src/test/shared/credentials/userCredentialsUtils.test.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,21 @@ describe('UserCredentialsUtils', function () {
2525
let tempFolder: string
2626
let defaultConfigFileName: string
2727
let defaultCredentialsFilename: string
28+
// preserve envs
29+
const credEnv = process.env['AWS_SHARED_CREDENTIALS_FILE']
30+
const configEnv = process.env['AWS_CONFIG_FILE']
2831

2932
before(async function () {
30-
defaultConfigFileName = getConfigFilename()
31-
defaultCredentialsFilename = getCredentialsFilename()
3233
// Make a temp folder for all these tests
3334
// Stick some temp credentials files in there to load from
3435
tempFolder = await makeTemporaryToolkitFolder()
36+
37+
// Set env to fake cred/config to avoid the actual aws config being deleted by test
38+
process.env.AWS_SHARED_CREDENTIALS_FILE = path.join(tempFolder, 'aws-credentials-tmp')
39+
process.env.AWS_CONFIG_FILE = path.join(tempFolder, 'aws-config-tmp')
40+
41+
defaultConfigFileName = getConfigFilename()
42+
defaultCredentialsFilename = getCredentialsFilename()
3543
})
3644

3745
afterEach(async function () {
@@ -43,6 +51,9 @@ describe('UserCredentialsUtils', function () {
4351

4452
after(async function () {
4553
await fs.delete(tempFolder, { recursive: true })
54+
// restore envs
55+
process.env['AWS_SHARED_CREDENTIALS_FILE'] = credEnv
56+
process.env['AWS_CONFIG_FILE'] = configEnv
4657
})
4758

4859
describe('findExistingCredentialsFilenames', function () {

0 commit comments

Comments
 (0)