-
Notifications
You must be signed in to change notification settings - Fork 212
Support for writing params of type List during discovery #1283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
76ddef0
Support for writing params of type List during discovery
Berlioz 9385598
Merge remote-tracking branch 'origin' into list_params
Berlioz 63410f7
selectList => multiSelect
Berlioz 452ff4a
list literals in CEL need to be []-delimited
Berlioz 1576281
Merge remote-tracking branch 'origin' into list_params
Berlioz a5b266e
Merge remote-tracking branch 'origin' into list_params
Berlioz 4ddaf79
Merge branch 'master' into list_params
Berlioz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
---|---|---|
|
@@ -27,6 +27,9 @@ describe("Params value extraction", () => { | |
process.env.PI = "3.14159"; | ||
process.env.TRUE = "true"; | ||
process.env.FALSE = "false"; | ||
process.env.LIST = JSON.stringify(["a", "b", "c"]); | ||
process.env.BAD_LIST = JSON.stringify(["a", 22, "c"]); | ||
process.env.ESCAPED_LIST = JSON.stringify(["f\to\no"]); | ||
process.env.A_SECRET_STRING = "123456supersecret"; | ||
}); | ||
|
||
|
@@ -42,6 +45,9 @@ describe("Params value extraction", () => { | |
delete process.env.PI; | ||
delete process.env.TRUE; | ||
delete process.env.FALSE; | ||
delete process.env.LIST; | ||
delete process.env.BAD_LIST; | ||
delete process.env.ESCAPED_LIST; | ||
delete process.env.A_SECRET_STRING; | ||
}); | ||
|
||
|
@@ -61,6 +67,11 @@ describe("Params value extraction", () => { | |
const falseParam = params.defineBoolean("FALSE"); | ||
expect(falseParam.value()).to.be.false; | ||
|
||
const listParam = params.defineList("LIST"); | ||
expect(listParam.value()).to.deep.equal(["a", "b", "c"]); | ||
|
||
const listParamWithEscapes = params.defineList("ESCAPED_LIST"); | ||
expect(listParamWithEscapes.value()).to.deep.equal(["f\to\no"]); | ||
const secretParam = params.defineSecret("A_SECRET_STRING"); | ||
expect(secretParam.value()).to.equal("123456supersecret"); | ||
}); | ||
|
@@ -97,6 +108,17 @@ describe("Params value extraction", () => { | |
|
||
const stringToBool = params.defineBoolean("A_STRING"); | ||
expect(stringToBool.value()).to.equal(false); | ||
|
||
const listToInt = params.defineInt("LIST"); | ||
expect(listToInt.value()).to.equal(0); | ||
}); | ||
|
||
it("falls back on the javascript zero values in case a list param's is unparsable as string[]", () => { | ||
const notAllStrings = params.defineList("BAD_LIST"); | ||
expect(notAllStrings.value()).to.deep.equal([]); | ||
|
||
const intToList = params.defineList("AN_INT"); | ||
expect(intToList.value()).to.deep.equal([]); | ||
}); | ||
|
||
it("returns a boolean value for Comparison expressions", () => { | ||
|
@@ -177,6 +199,18 @@ describe("Params value extraction", () => { | |
expect(trueParam.cmp("<=", false).value()).to.be.false; | ||
}); | ||
|
||
it("can test list params for equality but not < or >", () => { | ||
const p1 = params.defineList("LIST"); | ||
const p2 = params.defineList("ESCAPED_LIST"); | ||
|
||
expect(p1.equals(p1).value()).to.be.true; | ||
expect(p1.notEquals(p1).value()).to.be.false; | ||
expect(p1.equals(p2).value()).to.be.false; | ||
expect(p1.notEquals(p2).value()).to.be.true; | ||
|
||
expect(() => p1.greaterThan(p1).value()).to.throw; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is why I wish we had done operators in the type system with strong types for each expression type =/ |
||
}); | ||
|
||
it("can select the output of a ternary expression based on the comparison", () => { | ||
const trueExpr = params.defineString("A_STRING").equals(params.defineString("SAME_STRING")); | ||
expect(trueExpr.thenElse(1, 0).value()).to.equal(1); | ||
|
This file contains hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no action required - but i can see this being pretty frustrating if we silent fall back to an empty list if the list isn't made up of all string elements :/.
I don't think we expect this to happen in real life since environment variable will almost always be strings anyway?