2020-03-09 10:11:07 +01:00
|
|
|
# test code for the hg module
|
2021-01-07 07:44:20 +01:00
|
|
|
# Copyright: (c) 2018, Ansible Project
|
2020-03-09 10:11:07 +01:00
|
|
|
#
|
2021-01-07 07:44:20 +01:00
|
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
2020-03-09 10:11:07 +01:00
|
|
|
|
|
|
|
|
|
|
|
- name: set where to extract the repo
|
2021-01-07 07:44:20 +01:00
|
|
|
set_fact:
|
|
|
|
checkout_dir: "{{ output_dir }}/hg_project_test"
|
2020-03-09 10:11:07 +01:00
|
|
|
|
|
|
|
- name: set what repo to use
|
2021-01-07 07:44:20 +01:00
|
|
|
set_fact:
|
|
|
|
repo: "http://hg.pf.osdn.net/view/a/ak/akasurde/hg_project_test"
|
2020-03-09 10:11:07 +01:00
|
|
|
|
|
|
|
- name: clean out the output_dir
|
|
|
|
shell: rm -rf {{ output_dir }}/*
|
|
|
|
|
|
|
|
- name: verify that mercurial is installed so this test can continue
|
|
|
|
shell: which hg
|
|
|
|
|
|
|
|
- name: initial checkout
|
2021-01-07 07:44:20 +01:00
|
|
|
hg:
|
|
|
|
repo: "{{ repo }}"
|
|
|
|
dest: "{{ checkout_dir }}"
|
2020-03-09 10:11:07 +01:00
|
|
|
register: hg_result
|
|
|
|
|
|
|
|
- debug: var=hg_result
|
|
|
|
|
|
|
|
- shell: ls {{ checkout_dir }}
|
|
|
|
|
|
|
|
- name: verify information about the initial clone
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- "'before' in hg_result"
|
|
|
|
- "'after' in hg_result"
|
|
|
|
- "not hg_result.before"
|
|
|
|
- "hg_result.changed"
|
|
|
|
|
|
|
|
- name: repeated checkout
|
2021-01-07 07:44:20 +01:00
|
|
|
hg:
|
|
|
|
repo: "{{ repo }}"
|
|
|
|
dest: "{{ checkout_dir }}"
|
2020-03-09 10:11:07 +01:00
|
|
|
register: hg_result2
|
|
|
|
|
|
|
|
- debug: var=hg_result2
|
|
|
|
|
|
|
|
- name: check for tags
|
2021-01-07 07:44:20 +01:00
|
|
|
stat:
|
|
|
|
path: "{{ checkout_dir }}/.hgtags"
|
2020-03-09 10:11:07 +01:00
|
|
|
register: tags
|
|
|
|
|
|
|
|
- name: check for remotes
|
2021-01-07 07:44:20 +01:00
|
|
|
stat:
|
|
|
|
path: "{{ checkout_dir }}/.hg/branch"
|
2020-03-09 10:11:07 +01:00
|
|
|
register: branches
|
|
|
|
|
|
|
|
- debug: var=tags
|
|
|
|
- debug: var=branches
|
|
|
|
|
|
|
|
- name: assert presence of tags/trunk/branches
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- "tags.stat.isreg"
|
|
|
|
- "branches.stat.isreg"
|
|
|
|
|
2021-01-07 07:44:20 +01:00
|
|
|
- name: verify on a re-clone things are marked unchanged
|
2020-03-09 10:11:07 +01:00
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- "not hg_result2.changed"
|
|
|
|
|
|
|
|
- name: Checkout non-existent repo clone
|
2021-01-07 07:44:20 +01:00
|
|
|
hg:
|
|
|
|
repo: "http://hg.pf.osdn.net/view/a/ak/akasurde/hg_project_test_1"
|
|
|
|
clone: no
|
|
|
|
update: no
|
2020-03-09 10:11:07 +01:00
|
|
|
register: hg_result3
|
|
|
|
ignore_errors: true
|
|
|
|
|
|
|
|
- name: Verify result of non-existent repo clone
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- hg_result3.msg
|
|
|
|
- "'abort: HTTP Error 404: Not Found' in hg_result3.msg"
|
|
|
|
- "not hg_result3.changed"
|