1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/tests/integration/targets/filesize/tasks/symlinks.yml
Felix Fontein 1ab2a5f1bc
Add default license header to files which have no copyright or license header yet (#5074)
* Add default license header to files which have no copyright or license header yet.

* yml extension should have been xml...
2022-08-05 14:03:38 +02:00

97 lines
2.9 KiB
YAML

---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
# Check that the module works with symlinks, as expected, i.e. as dd does:
# follow symlinks.
- name: Ensure the test file is absent
ansible.builtin.file:
path: "{{ filesize_testfile }}"
state: absent
- name: Create a broken symlink in the same directory
ansible.builtin.file:
src: "{{ filesize_testfile | basename }}"
dest: "{{ filesize_testlink }}"
state: link
force: yes
follow: no
- name: Create a file with a size of 512 kB (512000 bytes) (check mode)
community.general.filesize:
path: "{{ filesize_testlink }}"
size: "512 kB"
register: filesize_test_symlink_01
check_mode: yes
- name: Create a file with a size of 512 kB (512000 bytes)
community.general.filesize:
path: "{{ filesize_testlink }}"
size: "512 kB"
register: filesize_test_symlink_02
- name: Stat the resulting file (not the symlink)
ansible.builtin.stat:
path: "{{ filesize_test_symlink_02.path }}"
register: filesize_stat_symlink_02
- name: Create a file with a size of 500 KiB (512000 bytes) (check mode, idempotency)
community.general.filesize:
path: "{{ filesize_testlink }}"
size: "500 KiB"
register: filesize_test_symlink_03
check_mode: yes
- name: Create a file with a size of 500 KiB (512000 bytes) (idempotency)
community.general.filesize:
path: "{{ filesize_testlink }}"
size: "500 KiB"
register: filesize_test_symlink_04
- name: Stat the file again (should remain the same)
ansible.builtin.stat:
path: "{{ filesize_test_symlink_04.path }}"
register: filesize_stat_symlink_04
- name: Assert that results are as expected
ansible.builtin.assert:
that:
- filesize_test_symlink_01 is changed
- filesize_test_symlink_02 is changed
- filesize_test_symlink_03 is not changed
- filesize_test_symlink_04 is not changed
- filesize_test_symlink_02.cmd == filesize_test_symlink_01.cmd
- filesize_test_symlink_03.cmd is undefined
- filesize_test_symlink_04.cmd is undefined
- filesize_test_symlink_01.state is undefined
- filesize_test_symlink_02.state in ["file"]
- filesize_test_symlink_01.size is undefined
- filesize_test_symlink_02.size == 512000
- filesize_test_symlink_03.size == 512000
- filesize_test_symlink_04.size == 512000
- filesize_stat_symlink_02.stat.size == 512000
- filesize_stat_symlink_04.stat.size == 512000
- filesize_test_symlink_04.path == filesize_test_symlink_02.path
- filesize_test_symlink_04.path != filesize_testlink
- name: Remove test file
ansible.builtin.file:
path: "{{ filesize_testfile }}"
state: absent
- name: Remove test link
ansible.builtin.file:
path: "{{ filesize_testlink }}"
state: absent