Skip to content

Commit

Permalink
Add molecule test for upload_helm_chart 'copy' method
Browse files Browse the repository at this point in the history
This patch also extends the molecule test to cover the case
where a new version of a chart is uploaded which should result
in a file being removed from the destination.
  • Loading branch information
Jonathan Rosser committed Dec 6, 2023
1 parent b8b9b56 commit 80b8623
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 4 deletions.
Empty file.
2 changes: 2 additions & 0 deletions molecule/upload-helm-chart/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@
become: true
roles:
- role: test-role
vars:
test_relative_path : "chart-v1/"
Empty file.
Empty file.
Empty file.
11 changes: 7 additions & 4 deletions molecule/upload-helm-chart/roles/test-role/meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
dependencies:
- role: vexxhost.kubernetes.upload_helm_chart
vars:
upload_helm_chart_src: "./files/chart/"
upload_helm_chart_dest: /usr/local/src/chart-1
# with rsync
upload_helm_chart_src: "{{ test_relative_path }}"
upload_helm_chart_dest: /usr/local/src/chart-one
- role: vexxhost.kubernetes.upload_helm_chart
vars:
upload_helm_chart_src: "../../charts/foo/"
upload_helm_chart_dest: /usr/local/src/chart-2
# with multi_copy
upload_helm_chart_src: "{{ test_relative_path }}"
upload_helm_chart_dest: /usr/local/src/chart-two
upload_helm_chart_method: copy
21 changes: 21 additions & 0 deletions molecule/upload-helm-chart/side_effect.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright (c) 2023 VEXXHOST, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

- name: Side effect
hosts: all
become: true
roles:
- role: test-role
vars:
test_relative_path: "chart-v2/"
30 changes: 30 additions & 0 deletions molecule/upload-helm-chart/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
- name: Verify
hosts: all
become: true
tasks:
- name: Stat file 1
ansible.builtin.stat:
path: /usr/local/src/chart-one/.gitkeep
register: stat_1

- name: Stat file 2
ansible.builtin.stat:
path: /usr/local/src/chart-two/.gitkeep
register: stat_2

- name: Stat removed file 1
ansible.builtin.stat:
path: /usr/local/src/chart-one/file
register: stat_r1

- name: Stat removed file 2
ansible.builtin.stat:
path: /usr/local/src/chart-two/file
register: stat_r2

- ansible.builtin.assert:
that:
- stat_1.stat.exists
- stat_2.stat.exists
- not stat_r1.stat.exists
- not stat_r2.stat.exists

0 comments on commit 80b8623

Please sign in to comment.