cannot reuse .env in expectedOutput
abdennour opened this issue · comments
My images are built by docker compose based on ARGs which are taken values from .env
.
I would like to make the assertion accordingly:
.env
NODE_TAG=11.8.0
config.yml
schemaVersion: '2.0.0'
globalEnvVars:
- key: "NODE_TAG"
value: "$NODE_TAG"
commandTests:
- name: "node version"
command: "node"
args: ["-v"]
expectedOutput: ["$NODE_TAG"]
When I ran tests, I got:
stdout
--- FAIL
stdout: v11.8.0
Error: Expected string '$NODE_TAG' not found in output 'v11.8.0
@abdennour thanks for the issue. my understanding was that .env
files can be read by the shell when directed to (via source .env
or sh .env
, but not by default, so I'm not entirely sure I understand your use case. would you be interested in sending a fix for this?
as a workaround i use something like this for the command test:
command: "sh"
args:
- -c
- |
if node -v | grep "$NODE_TAG" ; then
exit 0
else
exit 1
fi