File tree Expand file tree Collapse file tree 3 files changed +42
-3
lines changed
packages/idempotency/tests Expand file tree Collapse file tree 3 files changed +42
-3
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,12 @@ const populateEnvironmentVariables = (): void => {
2
2
process . env . AWS_LAMBDA_FUNCTION_NAME = 'hello-world' ;
3
3
4
4
} ;
5
+
6
+ const deleteEnvironmentVariables = ( ) : void => {
7
+ delete process . env . AWS_LAMBDA_FUNCTION_NAME ;
8
+ }
5
9
6
10
export {
11
+ deleteEnvironmentVariables ,
7
12
populateEnvironmentVariables ,
8
13
} ;
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Test Tracer class
3
+ *
4
+ * @group unit/idempotency/all
5
+ */
6
+ import { EnvironmentVariablesService } from '../../src/EnvironmentVariablesService' ;
7
+
8
+ describe ( 'Class: EnvironmentVariableService' , ( ) => {
9
+ describe ( 'Method: getLambdaFunctionName' , ( ) => {
10
+ beforeEach ( ( ) => {
11
+ process . env . AWS_LAMBDA_FUNCTION_NAME = 'testFunction' ;
12
+ } ) ;
13
+
14
+ afterEach ( ( ) => {
15
+ delete process . env . AWS_LAMBDA_FUNCTION_NAME ;
16
+ } ) ;
17
+
18
+ test ( 'When called it getse the Lambda function name from the environment variable' , ( ) => {
19
+ const expectedName = process . env . AWS_LAMBDA_FUNCTION_NAME ;
20
+
21
+ const lambdaName = new EnvironmentVariablesService ( ) . getLambdaFunctionName ( ) ;
22
+
23
+ expect ( lambdaName ) . toEqual ( expectedName ) ;
24
+ } ) ;
25
+
26
+ test ( 'When called without the environment variable set it returns an empty string' , ( ) => {
27
+ delete process . env . AWS_LAMBDA_FUNCTION_NAME ;
28
+
29
+ const lambdaName = new EnvironmentVariablesService ( ) . getLambdaFunctionName ( ) ;
30
+
31
+ expect ( lambdaName ) . toEqual ( '' ) ;
32
+ } ) ;
33
+ } ) ;
34
+ } ) ;
Original file line number Diff line number Diff line change 4
4
* @group unit/idempotency/all
5
5
*/
6
6
import { createHash , Hash } from 'crypto' ;
7
- import { EnvironmentVariablesService } from '../../src/EnvironmentVariablesService' ;
8
- import { IdempotencyRecord , PersistenceLayer } from '../../src/persistence' ;
9
- import { IdempotencyRecordStatus } from '../../src/types/IdempotencyRecordStatus' ;
7
+ import { EnvironmentVariablesService } from '../../../ src/EnvironmentVariablesService' ;
8
+ import { IdempotencyRecord , PersistenceLayer } from '../../../ src/persistence' ;
9
+ import { IdempotencyRecordStatus } from '../../../ src/types/IdempotencyRecordStatus' ;
10
10
11
11
jest . mock ( 'crypto' , ( ) => ( {
12
12
createHash : jest . fn ( ) ,
You can’t perform that action at this time.
0 commit comments