Skip to content

Commit

Permalink
feat: use testplane env prefix with hermione fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
KuznetsovRoman committed Apr 2, 2024
1 parent 65bd275 commit 686787d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 12 deletions.
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"expect-webdriverio": "3.5.3",
"fastq": "1.13.0",
"fs-extra": "5.0.0",
"gemini-configparser": "1.3.0",
"gemini-configparser": "1.4.1",
"glob-extra": "5.0.2",
"lodash": "4.17.21",
"looks-same": "9.0.0",
Expand Down
4 changes: 2 additions & 2 deletions src/config/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const optionsBuilder = require("./options-builder");

const options = optionsBuilder(_.propertyOf(defaults));

const ENV_PREFIX = `${require("../../package").name}_`;
const ENV_PREFIXES = ["testplane_", "hermione_"];

const rootSection = section(
_.extend(browserOptions.getTopLevel(), {
Expand Down Expand Up @@ -104,4 +104,4 @@ const rootSection = section(
}),
);

module.exports = root(rootSection, { envPrefix: ENV_PREFIX });
module.exports = root(rootSection, { envPrefix: ENV_PREFIXES });
12 changes: 12 additions & 0 deletions test/src/config/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,18 @@ describe("config options", () => {
assert.deepEqual(result.system[optionName], { some: "opts" });
});

it("should prefer existing environment option with testplane_ prefix", () => {
const result = parse_({
options: { system: { [optionName]: {} } },
env: {
[`hermione_system_${_.snakeCase(optionName)}`]: '{"foo": "bar"}',
[`testplane_system_${_.snakeCase(optionName)}`]: '{"baz": "qux"}',
},
});

assert.deepEqual(result.system[optionName], { baz: "qux" });
});

it("should parse option from cli", () => {
const result = parse_({
options: { system: { [optionName]: {} } },
Expand Down

0 comments on commit 686787d

Please sign in to comment.