Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add test for changing git remote url #13170

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
40 changes: 40 additions & 0 deletions test/integration/roles/test_git/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
repo_submodule1: 'https://github.com/abadger/test_submodules_subm1.git'
repo_submodule1_newer: 'https://github.com/abadger/test_submodules_subm1_newer.git'
repo_submodule2: 'https://github.com/abadger/test_submodules_subm2.git'
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'
known_host_files:
- "{{ lookup('env','HOME') }}/.ssh/known_hosts"
- '/etc/ssh/ssh_known_hosts'
Expand Down Expand Up @@ -346,3 +348,41 @@

- assert:
that: '{{ submodule2.stdout_lines|length }} == 4'
# test change of repo url
# see https://github.com/ansible/ansible-modules-core/pull/721

- name: clear checkout_dir
file: state=absent path={{ checkout_dir }}

- name: Clone example git repo
git:
repo: '{{ repo_update_url_1 }}'
dest: '{{ checkout_dir }}'

- name: Clone repo with changed url to the same place
git:
repo: '{{ repo_update_url_2 }}'
dest: '{{ checkout_dir }}'
register: clone2

- assert:
that: "clone2|success"

- name: check url updated
shell: git remote show origin | grep Fetch
register: remote_url
args:
chdir: '{{ checkout_dir }}'

- assert:
that:
- "'git-test-new' in remote_url.stdout"
- "'git-test-old' not in remote_url.stdout"

- name: check for new content in git-test-new
stat: path={{ checkout_dir }}/newfilename
register: repo_content

- name: assert presence of new file in repo (i.e. working copy updated)
assert:
that: "repo_content.stat.exists"