Skip to content

Commit

Permalink
fix: static method Configurator.getEnvConfig() (#282)
Browse files Browse the repository at this point in the history
* fixing static method getEnvConfig

* fixing test
  • Loading branch information
malachi-constant committed Mar 21, 2023
1 parent dbc8bfc commit b2dc1f7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 26 deletions.
3 changes: 2 additions & 1 deletion src/config/configurator.ts
Expand Up @@ -129,7 +129,8 @@ export interface GetEnvConfigProps {

export class Configurator {
public static getEnvConfig(props: GetEnvConfigProps): any {
return getConfig({ config: props.configPath })[props.environmentId];
const config = getConfig({ config: props.configPath });
return config.environments ? config.environments[props.environmentId] : undefined;
}
public readonly config: any;
public readonly environmentId?: string;
Expand Down
34 changes: 9 additions & 25 deletions test/config.test.ts
Expand Up @@ -381,34 +381,18 @@ test("Get Env Config", () => {

test("Get Env Config Static Method", () => {
const config = Configurator.getEnvConfig({ configPath: "./test/test-config.yaml", environmentId: "dev" });
const nullConfig = Configurator.getEnvConfig({ configPath: "./ddk.json", environmentId: "dev" });
const expectedDevConfig = {
tags: {
"global:foo": "bar",
},
environments: {
dev: {
account: "222222222222",
region: "us-east-1",
resources: {
"AWS::Lambda::Function": {
MemorySize: 128,
Runtime: "python3.8",
},
},
tags: { CostCenter: "2014" },
},
prod: {
account: "222222222222",
region: "us-east-1",
resources: {
"AWS::Lambda::Function": {
MemorySize: 1024,
Runtime: "python3.8",
},
},
tags: { CostCenter: "2015" },
account: "222222222222",
region: "us-east-1",
resources: {
"AWS::Lambda::Function": {
MemorySize: 128,
Runtime: "python3.8",
},
},
tags: { CostCenter: "2014" },
};
assert(config === expectedDevConfig);
assert(nullConfig === undefined);
});

0 comments on commit b2dc1f7

Please sign in to comment.