/test/integration/roles/test_win_stat/tasks/main.yml

https://github.com/ajanthanm/ansible · YAML · 80 lines · 53 code · 11 blank · 16 comment · 0 complexity · 18130c0d21d30e264c6c0ab9f95d63d8 MD5 · raw file

  1. # test code for the win_stat module
  2. # (c) 2014, Chris Church <chris@ninemoreminutes.com>
  3. # This file is part of Ansible
  4. #
  5. # Ansible is free software: you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation, either version 3 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # Ansible is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with Ansible. If not, see <http://www.gnu.org/licenses/>.
  17. - name: test win_stat module on file
  18. win_stat: path="C:/Windows/win.ini"
  19. register: win_stat_file
  20. - name: check win_stat file result
  21. assert:
  22. that:
  23. - "win_stat_file.stat.exists"
  24. - "not win_stat_file.stat.isdir"
  25. - "win_stat_file.stat.size > 0"
  26. - "win_stat_file.stat.md5"
  27. - "not win_stat_file|failed"
  28. - "not win_stat_file|changed"
  29. - name: test win_stat module on file without md5 and backslashes
  30. win_stat: path="C:\Windows\win.ini" get_md5=no
  31. register: win_stat_file_no_md5
  32. - name: check win_stat file result without md
  33. assert:
  34. that:
  35. - "win_stat_file_no_md5.stat.exists"
  36. - "not win_stat_file_no_md5.stat.isdir"
  37. - "win_stat_file_no_md5.stat.size > 0"
  38. - "not win_stat_file_no_md5.stat.md5|default('')"
  39. - "not win_stat_file_no_md5|failed"
  40. - "not win_stat_file_no_md5|changed"
  41. - name: test win_stat module on directory
  42. win_stat: path="C:\\Windows"
  43. register: win_stat_dir
  44. - name: check win_stat dir result
  45. assert:
  46. that:
  47. - "win_stat_dir.stat.exists"
  48. - "win_stat_dir.stat.isdir"
  49. - "not win_stat_dir|failed"
  50. - "not win_stat_dir|changed"
  51. - name: test win_stat module non-existent path
  52. win_stat: path="C:/this_file_should_not_exist.txt"
  53. register: win_stat_missing
  54. - name: check win_stat missing result
  55. assert:
  56. that:
  57. - "not win_stat_missing.stat.exists"
  58. - "not win_stat_missing|failed"
  59. - "not win_stat_missing|changed"
  60. - name: test win_stat module without path argument
  61. action: win_stat
  62. register: win_stat_no_args
  63. ignore_errors: true
  64. - name: check win_stat result witn no path argument
  65. assert:
  66. that:
  67. - "win_stat_no_args|failed"
  68. - "win_stat_no_args.msg"
  69. - "not win_stat_no_args|changed"