Add tests for affected code path

pull/80456/head
Joshua Salzedo 2 years ago
parent 8e18f34ddf
commit f432feb846

@ -148,3 +148,51 @@
- name: SUBMODULES | Ensure submodule1 is at the appropriate commit - name: SUBMODULES | Ensure submodule1 is at the appropriate commit
assert: assert:
that: '{{ submodule1.stdout_lines | length }} == 4' that: '{{ submodule1.stdout_lines | length }} == 4'
- name: SUBMODULES | clear checkout_dir
file:
state: absent
path: "{{ checkout_dir }}"
- name: SUBMODULES | Clone main_b submodule repository
git:
repo: "{{ repo_submodules_b }}"
dest: "{{ checkout_dir }}/test.gitdir"
recursive: yes # checkout the submodules as-is.
# For the initial clone, don't track submodules.
# this is done to simulate e.g. updating a repository that already exists.
track_submodules: no
- name: SUBMODULES | update main_b submodule repository
git:
repo: "{{ repo_submodules_b }}"
dest: "{{ checkout_dir }}/test.gitdir"
recursive: yes
# Track the submodules in the second deployment, to simulate updating an existing repository.
track_submodules: yes
- name: SUBMODULES | check presense of submodule3's flag
stat:
path: "{{ checkout_dir }}/test.gitdir/submodule3/FLAG"
# submodule3's commited state does not have this file, but the tip of the branch in .gitmodules has this file.
# for track_submodules to have behaved correctly, this file must exist in the checkout.
register: submodule3_flag_stat
- name: SUBMODULES | check presense of submodule4's flag
stat:
path: "{{ checkout_dir }}/test.gitdir/submodule4/FLAG"
# submodule4's commited state and tip of tracked branch have the FLAG present.
# however, a canary `master` branch exists with the flag removed.
# for track_submodules to have behaved correctly, this file must be present.
register: submodule4_flag_stat
- name: SUBMODULES | Assert submodule3 FLAG is present.
assert:
that: submodule3_flag_stat.stat.exists
msg: "submodule3's FLAG must exist on this branch, but its missing!"
- name: SUBMODULES | Assert submodule4 FLAG is present.
assert:
that: submodule4_flag_stat.stat.exists
msg: "submodule4's FLAG must exist on this branch, but its missing!"
- name: SUBMODULES | clear checkout_dir
file:
state: absent
path: "{{ checkout_dir }}"

@ -36,6 +36,9 @@ repo_format3: 'ssh://git@github.com/jimi-c/test_role.git'
repo_submodules: 'https://github.com/abadger/test_submodules_newer.git' repo_submodules: 'https://github.com/abadger/test_submodules_newer.git'
repo_submodule1: 'https://github.com/abadger/test_submodules_subm1.git' repo_submodule1: 'https://github.com/abadger/test_submodules_subm1.git'
repo_submodule2: 'https://github.com/abadger/test_submodules_subm2.git' repo_submodule2: 'https://github.com/abadger/test_submodules_subm2.git'
repo_submodules_b: 'https://github.com/theunkn0wn1/ansible_test_submodules_monorepo.git'
repo_submodule3: 'https://github.com/theunkn0wn1/ansible_test_submodules_subm3.git'
repo_submodule4: 'https://github.com/theunkn0wn1/ansible_test_submodules_subm4.git'
repo_update_url_1: 'https://github.com/ansible-test-robinro/git-test-old' repo_update_url_1: 'https://github.com/ansible-test-robinro/git-test-old'
repo_update_url_2: 'https://github.com/ansible-test-robinro/git-test-new' repo_update_url_2: 'https://github.com/ansible-test-robinro/git-test-new'
known_host_files: known_host_files:

Loading…
Cancel
Save