You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to define a variable with contains a random value and want to inject it somehow into tests executed by trycmd. I can mask the value with insert_var(..) and tried to use env(..) to make the variable accessible in my tests but something like $ echo $TEST_VALUE never substitutes the variable with the value given to env(..). Is there some way to access the value behind a variable?
The text was updated successfully, but these errors were encountered:
If I'm understanding correctly, you are wanting to access environment variables on the "command-line" as these are inputs that are determined at runtime?
yeah exactly! A simplified code example looks like this:
let key = "some-randomly-generated-value";
trycmd::TestCases::new().case("tests/cmd/secrets/*.md").env("KEY", key).insert_var("[KEY]", key).unwrap();
and I want to run a test like this:
$ bin-command secrets add $KEYkey '[KEY]' added
my current workaround is to write the generated value into a file, add that file to gitignore (so that it won't get flagged by security scans..) and allow my add subcommand to read from files
epage
changed the title
trycmd: allow to set substitutable variables
trycmd: allow access to environment variables within a trycmd command-line
Sep 17, 2024
As we have another concept of substitutions (also called redactions) in terms of insert_var, I've clarified the issue name.
This is another part in the overall story thats building up in issues of "it would be nice if we had an embedded shell to work with". We have requests for pipes (#172) and some common unix built-ins (e.g. #168, #43)
I'm trying to define a variable with contains a random value and want to inject it somehow into tests executed by trycmd. I can mask the value with
insert_var(..)
and tried to useenv(..)
to make the variable accessible in my tests but something like$ echo $TEST_VALUE
never substitutes the variable with the value given toenv(..)
. Is there some way to access the value behind a variable?The text was updated successfully, but these errors were encountered: