summaryrefslogtreecommitdiff
path: root/test/integration/targets/win_pester/tasks/main.yml
blob: ca04a1fe5a22b0f9c5fbc358dc116e9de42303ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
---
- name: create test folder(s)
  win_file:
    path: '{{test_win_pester_path}}\{{item}}'
    state: directory
  with_items:
  - Modules
  - Tests

- name: download Pester module from S3 bucket
  win_get_url:
    # this was downloaded straight off the Pester GitHub release page and uploaded to the S3 bucket
    # https://github.com/pester/Pester/releases 
    url: 'https://ansible-ci-files.s3.amazonaws.com/test/integration/roles/test_win_pester/Pester-4.3.1.zip'
    dest: '{{test_win_pester_path}}\Pester-4.3.1.zip'

- name: unzip Pester module
  win_unzip:
    src: '{{test_win_pester_path}}\Pester-4.3.1.zip'
    dest: '{{test_win_pester_path}}\Modules'

- name: rename extracted zip to match module name
  win_shell: Rename-Item -Path '{{test_win_pester_path}}\Modules\Pester-4.3.1' -NewName Pester

- name: add custom Pester location to the PSModulePath
  win_path:
    name: PSModulePath
    scope: machine
    state: present
    elements:
    - '{{test_win_pester_path}}\Modules'

- name: copy test files
  win_copy:
    src: files/
    dest: '{{test_win_pester_path}}\Tests'

- block:
  - name: run Pester tests
    include_tasks: test.yml
    vars:
      test_path: '{{ test_win_pester_path }}\Tests'

  always:
  - name: remove custom pester location on the PSModulePath
    win_path:
      name: PSModulePath
      scope: machine
      state: absent
      elements:
      - '{{test_win_pester_path}}\Modules'

  - name: delete test folder
    win_file:
      path: '{{test_win_pester_path}}'
      state: absent