Skip to content

Commit

Permalink
Add tests for env files
Browse files Browse the repository at this point in the history
Signed-off-by: Sagi Shnaidman <[email protected]>
  • Loading branch information
sshnaidm committed Jan 27, 2024
1 parent 2e661d1 commit 2536106
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions tests/integration/targets/podman_container/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,71 @@
that:
- not service2_file.stat.exists | bool

- name: Create environment variables files
copy:
dest: /tmp/envfile
content: |
FOO=bar
BAR=foo
TEST=1
BOOL=false
- name: Create another environment variables files
copy:
dest: /tmp/envfile2
content: |
TESTVAR=qwerty
- name: Create container with environment variables file
containers.podman.podman_container:
executable: "{{ test_executable | default('podman') }}"
name: container1
image: alpine
state: started
command:
- sh
- -c
- echo $BAR
attach:
- stdout
- stderr
env_file: /tmp/envfile
register: envfile

- name: Check output is correct for env file
assert:
that:
- envfile.stdout == "foo\n"

- name: Create container with multiple environment variables files
containers.podman.podman_container:
executable: "{{ test_executable | default('podman') }}"
name: container1
image: alpine
state: started
command:
- sh
- -c
- echo $TESTVAR
attach:
- stdout
- stderr
env_file:
- /tmp/envfile
- /tmp/envfile2
register: envfile2

- name: Check output is correct for multiple env files
assert:
that:
- envfile2.stdout == "qwerty\n"

- name: Delete container with environment variables file
containers.podman.podman_container:
executable: "{{ test_executable | default('podman') }}"
name: container1
state: absent

- name: Create temporary rootfs directory
ansible.builtin.tempfile:
state: directory
Expand Down

0 comments on commit 2536106

Please sign in to comment.