# win_shell invocations can eventually be replaced with win_eventlog
- name: Remove potentially leftover test logs and sources
  win_shell: Remove-EventLog -LogName "{{ item.log }}" -ErrorAction SilentlyContinue
  with_items:
    - "{{ win_test_log_source }}"
    - "{{ win_test_log_source_extra }}"
  failed_when: no

- name: Add new test logs and sources
  win_shell: New-EventLog -LogName "{{ item.log }}" -Source "{{ item.source }}"
  with_items:
    - "{{ win_test_log_source }}"
    - "{{ win_test_log_source_extra }}"

- name: Run tests for win_eventlog_entry
  block:

  - name: Test in normal mode
    import_tasks: tests.yml
    vars:
      in_check_mode: no

  - name: Test in check-mode
    import_tasks: tests.yml
    vars:
      in_check_mode: yes
    check_mode: yes

- name: Remove test logs and sources
  win_shell: Remove-EventLog -LogName "{{ item.log }}"
  with_items:
    - "{{ win_test_log_source }}"
    - "{{ win_test_log_source_extra }}"
