Skip to content

Commit

Permalink
alernatives: Add integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jiuka committed May 10, 2022
1 parent fc2b694 commit 910e7fe
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/integration/targets/alternatives/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
# Test that path is checked: alternatives must fail when path is nonexistent
- import_tasks: path_is_checked.yml

# Test that slave commands work
- import_tasks: slaves.yml

# Test operation of the 'state' parameter
- block:
- include_tasks: remove_links.yml
Expand Down
35 changes: 35 additions & 0 deletions tests/integration/targets/alternatives/tasks/slaves.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
- name: Try with slaves
alternatives:
name: dummymain
path: '/usr/bin/dummy1'
link: '/usr/bin/dummymain'
slaves:
- name: dummyslave
path: '/usr/bin/dummy2'
link: '/usr/bin/dummyslave'
ignore_errors: True
register: alternative

- name: check expected command was executed
assert:
that:
- 'alternative is successful'
- 'alternative is changed'

- name: Execute the current dummymain command
shell: dummymain
register: cmd

- name: Ensure that the expected command was executed
assert:
that:
- cmd.stdout == "dummy1"

- name: Execute the current dummyslave command
shell: dummyslave
register: cmd

- name: Ensure that the expected command was executed
assert:
that:
- cmd.stdout == "dummy2"

0 comments on commit 910e7fe

Please sign in to comment.