summaryrefslogtreecommitdiff
path: root/test/integration/targets/win_unzip/tasks/main.yml
blob: 2dab84be563b01d291fa2aec60fb0509746608b5 (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
---
- name: create test directory
  win_file:
    path: '{{ win_unzip_dir }}\output'
    state: directory

- name: create local zip file with non-ascii chars
  script: create_zip.py {{ output_dir + '/win_unzip.zip' | quote }}
  delegate_to: localhost

- name: copy across zip to Windows host
  win_copy:
    src: '{{ output_dir }}/win_unzip.zip'
    dest: '{{ win_unzip_dir }}\win_unzip.zip'

- name: unarchive zip (check)
  win_unzip:
    src: '{{ win_unzip_dir }}\win_unzip.zip'
    dest: '{{ win_unzip_dir }}\output'
  register: unzip_check
  check_mode: yes

- name: get result of unarchive zip (check)
  win_stat:
    path: '{{ win_unzip_dir }}\output\café.txt'
  register: unzip_actual_check

- name: assert result of unarchive zip (check)
  assert:
    that:
    - unzip_check is changed
    - not unzip_check.removed
    - not unzip_actual_check.stat.exists

- name: unarchive zip
  win_unzip:
    src: '{{ win_unzip_dir }}\win_unzip.zip'
    dest: '{{ win_unzip_dir }}\output'
  register: unzip

- name: get result of unarchive zip
  slurp:
    path: '{{ win_unzip_dir }}\output\café.txt'
  register: unzip_actual

- name: assert result of unarchive zip
  assert:
    that:
    - unzip is changed
    - not unzip.removed
    - unzip_actual.content | b64decode == 'café.txt'

# Module is not idempotent, will always change without creates
- name: unarchive zip again without creates
  win_unzip:
    src: '{{ win_unzip_dir }}\win_unzip.zip'
    dest: '{{ win_unzip_dir }}\output'
  register: unzip_again

- name: assert unarchive zip again without creates
  assert:
    that:
    - unzip_again is changed
    - not unzip_again.removed

- name: unarchive zip with creates
  win_unzip:
    src: '{{ win_unzip_dir }}\win_unzip.zip'
    dest: '{{ win_unzip_dir }}\outout'
    creates: '{{ win_unzip_dir }}\output\café.txt'
  register: unzip_again_creates

- name: assert unarchive zip with creates
  assert:
    that:
    - not unzip_again_creates is changed
    - not unzip_again_creates.removed

- name: unarchive zip with delete (check)
  win_unzip:
    src: '{{ win_unzip_dir }}\win_unzip.zip'
    dest: '{{ win_unzip_dir }}\output'
    delete_archive: yes
  register: unzip_delete_check
  check_mode: yes

- name: get result of unarchive zip with delete (check)
  win_stat:
    path: '{{ win_unzip_dir }}\win_unzip.zip'
  register: unzip_delete_actual_check

- name: assert unarchive zip with delete (check)
  assert:
    that:
    - unzip_delete_check is changed
    - unzip_delete_check.removed
    - unzip_delete_actual_check.stat.exists

- name: unarchive zip with delete
  win_unzip:
    src: '{{ win_unzip_dir }}\win_unzip.zip'
    dest: '{{ win_unzip_dir }}\output'
    delete_archive: yes
  register: unzip_delete

- name: get result of unarchive zip with delete
  win_stat:
    path: '{{ win_unzip_dir }}\win_unzip.zip'
  register: unzip_delete_actual

- name: assert unarchive zip with delete
  assert:
    that:
    - unzip_delete is changed
    - unzip_delete.removed
    - not unzip_delete_actual.stat.exists