-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(tests): resolve test synatx errors found while testing after upgrade
- Loading branch information
1 parent
123208c
commit feb35f6
Showing
13 changed files
with
80 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
export enum Stage { | ||
PRODUCTION = 'prod', | ||
DEVELOPMENT = 'dev', | ||
TEST = 'test', | ||
} | ||
|
||
/** | ||
* this allows us to infer what the stage should be in environments that do not have STAGE specified | ||
* - e.g., when running locally | ||
* - e.g., when running tests | ||
*/ | ||
const inferStageFromNodeEnv = () => { | ||
const nodeEnv = process.env.NODE_ENV; // default to test if not defined | ||
if (!nodeEnv) throw new Error('process.env.NODE_ENV must be defined'); | ||
if (nodeEnv === 'production') return Stage.PRODUCTION; | ||
if (nodeEnv === 'development') return Stage.DEVELOPMENT; | ||
if (nodeEnv === 'test') return Stage.TEST; | ||
throw new Error(`unexpected nodeEnv '${nodeEnv}'`); | ||
}; | ||
|
||
/** | ||
* a method that exposes relevant environmental variables in a standard way | ||
*/ | ||
const getEnvironment = () => { | ||
const stage = process.env.STAGE ?? inferStageFromNodeEnv(); // figure it out from NODE_ENV if not explicitly defined | ||
if (!stage) throw new Error('process.env.STAGE must be defined'); | ||
return { stage }; | ||
}; | ||
|
||
// export stage immediately, since it does not change | ||
export const { stage } = getEnvironment(); | ||
|
||
// export service client stage | ||
export const serviceClientStage = | ||
stage === Stage.PRODUCTION ? Stage.PRODUCTION : Stage.DEVELOPMENT; // i.e., if its prod, hit prod. otherwise, dev |