@@ -29,6 +29,7 @@ import { captureEventOnce } from '../../test/testUtil'
29
29
import { toStream } from '../../shared/utilities/collectionUtils'
30
30
import { toCollection } from '../../shared/utilities/asyncCollection'
31
31
import { getLogger } from '../../shared/logger'
32
+ import { isAwsError } from '../../shared/errors'
32
33
33
34
let spaceName : CodeCatalystOrg [ 'name' ]
34
35
let projectName : CodeCatalystProject [ 'name' ]
@@ -238,6 +239,30 @@ describe('Test how this codebase uses the CodeCatalyst API', function () {
238
239
assert ( lsOutput . split ( '\n' ) . includes ( expectedFile ) )
239
240
} )
240
241
242
+ it ( 'has environment variables that identify the Dev Environment' , async function ( ) {
243
+ const { SessionProcess, hostname, sshPath } = await prepareDevEnvConnection ( client , {
244
+ ...defaultDevEnv ,
245
+ } )
246
+
247
+ const output = (
248
+ await new SessionProcess ( sshPath , [ hostname , 'printenv' , '|' , 'grep' , '__DEV_ENVIRONMENT' ] ) . run ( )
249
+ ) . stdout
250
+
251
+ const parsed : Record < string , string > = { }
252
+ for ( const line of output . split ( '\n' ) ) {
253
+ const [ _ , key , value ] = line . match ( / ( .* ) = ( .* ) / ) ?? [ ]
254
+ if ( ! key || ! value ) {
255
+ throw new Error ( `Failed to parse environment variables from dev env` )
256
+ }
257
+
258
+ parsed [ key ] = value
259
+ }
260
+
261
+ assert . deepStrictEqual ( parsed [ '__DEV_ENVIRONMENT_ID' ] , defaultDevEnv . id )
262
+ assert . deepStrictEqual ( parsed [ '__DEV_ENVIRONMENT_PROJECT_NAME' ] , defaultDevEnv . project . name )
263
+ assert . deepStrictEqual ( parsed [ '__DEV_ENVIRONMENT_ORGANIZATION_NAME' ] , defaultDevEnv . org . name )
264
+ } )
265
+
241
266
/**
242
267
* IMPORTANT: This test takes a while to run. Stopping a Dev Env takes time.
243
268
*/
@@ -419,11 +444,22 @@ describe('Test how this codebase uses the CodeCatalyst API', function () {
419
444
spaceName : CodeCatalystOrg [ 'name' ] ,
420
445
projectName : CodeCatalystProject [ 'name' ] = 'aws-vscode-toolkit-integ-test-project'
421
446
) : Promise < CodeCatalystProject > {
422
- return client . createProject ( {
423
- spaceName,
424
- displayName : projectName ,
425
- description : 'This project is autogenerated by the AWS Toolkit VSCode Integ Test.' ,
426
- } )
447
+ try {
448
+ return await client . createProject ( {
449
+ spaceName,
450
+ displayName : projectName ,
451
+ description : 'This project is autogenerated by the AWS Toolkit VSCode Integ Test.' ,
452
+ } )
453
+ } catch ( e ) {
454
+ if ( isAwsError ( e ) && e . code === 'ConflictException' ) {
455
+ return client . getProject ( {
456
+ spaceName,
457
+ name : projectName ,
458
+ } )
459
+ }
460
+
461
+ throw e
462
+ }
427
463
}
428
464
429
465
/**
0 commit comments