-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1308 from Genez-io/add-backend-environment
Add backend.environment to the configuration file
- Loading branch information
Showing
6 changed files
with
257 additions
and
8 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
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,40 @@ | ||
import { describe, it, expect } from "vitest"; | ||
import { parseConfigurationVariable } from "../../src/utils/environmentVariables"; | ||
|
||
describe("parseConfigurationVariable", () => { | ||
it("should parse env variable correctly", async () => { | ||
const rawValue = "${{ env.MY_ENV_VAR }}"; | ||
const result = await parseConfigurationVariable(rawValue); | ||
expect(result).toEqual({ key: "MY_ENV_VAR" }); | ||
}); | ||
|
||
it("should parse backend functions variable correctly", async () => { | ||
const rawValue = "${{ backend.functions.myFunction.url }}"; | ||
const result = await parseConfigurationVariable(rawValue); | ||
expect(result).toEqual({ path: "backend.functions.myFunction", field: "url" }); | ||
}); | ||
|
||
it("should return raw value if no match is found", async () => { | ||
const rawValue = "plainValue"; | ||
const result = await parseConfigurationVariable(rawValue); | ||
expect(result).toEqual({ value: "plainValue" }); | ||
}); | ||
|
||
it("should handle cases with spaces correctly for env variables", async () => { | ||
const rawValue = "${{ env.MY_ENV_VAR }}"; | ||
const result = await parseConfigurationVariable(rawValue); | ||
expect(result).toEqual({ key: "MY_ENV_VAR" }); | ||
}); | ||
|
||
it("should handle cases with spaces correctly for backend functions", async () => { | ||
const rawValue = "${{ backend.functions.myFunction.url }}"; | ||
const result = await parseConfigurationVariable(rawValue); | ||
expect(result).toEqual({ path: "backend.functions.myFunction", field: "url" }); | ||
}); | ||
|
||
it("should return raw value if format is incorrect", async () => { | ||
const rawValue = "${{ some.incorrect.format }"; | ||
const result = await parseConfigurationVariable(rawValue); | ||
expect(result).toEqual({ value: rawValue }); | ||
}); | ||
}); |