Skip to content

Commit 5731513

Browse files
committed
Add state-locked tests
1 parent e4a43bf commit 5731513

File tree

1 file changed

+54
-8
lines changed

1 file changed

+54
-8
lines changed

.github/workflows/test-unlock-state.yaml

Lines changed: 54 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,36 +46,82 @@ jobs:
4646
fi
4747
4848
# Check state-locked
49-
- name: Try using locked state
49+
- name: Try using locked state using terraform-apply
5050
uses: ./terraform-apply
51-
id: locked-state
51+
id: locked-state-apply
5252
continue-on-error: true
5353
with:
5454
path: tests/workflows/test-unlock-state
5555
auto_approve: true
5656

57-
- name: Check state locked failure-reason
57+
- name: Check terraform-apply state locked failure-reason
58+
run: |
59+
if [[ "${{ steps.locked-state-apply.outcome }}" != "failure" ]]; then
60+
echo "Apply did not fail correctly"
61+
exit 1
62+
fi
63+
64+
if [[ "${{ steps.locked-state-apply.outputs.failure-reason }}" != "state-locked" ]]; then
65+
echo "::error:: failure-reason not set correctly"
66+
exit 1
67+
fi
68+
69+
echo '"${{ steps.locked-state-apply.outputs.lock-info }}"'
70+
71+
echo 'Lock id is ${{ fromJson(steps.locked-state-apply.outputs.lock-info).ID }}'
72+
73+
- name: Try using locked state using terraform-destroy
74+
uses: ./terraform-destroy
75+
id: locked-state-destroy
76+
continue-on-error: true
77+
with:
78+
path: tests/workflows/test-unlock-state
79+
80+
- name: Check terraform-destroy state locked failure-reason
81+
run: |
82+
if [[ "${{ steps.locked-state-destroy.outcome }}" != "failure" ]]; then
83+
echo "Apply did not fail correctly"
84+
exit 1
85+
fi
86+
87+
if [[ "${{ steps.locked-state-destroy.outputs.failure-reason }}" != "state-locked" ]]; then
88+
echo "::error:: failure-reason not set correctly"
89+
exit 1
90+
fi
91+
92+
echo '"${{ steps.locked-state-destroy.outputs.lock-info }}"'
93+
94+
echo 'Lock id is ${{ fromJson(steps.locked-state-destroy.outputs.lock-info).ID }}'
95+
96+
- name: Try using locked state using terraform-destroy-workspace
97+
uses: ./terraform-destroy-workspace
98+
id: locked-state-destroy-workspace
99+
continue-on-error: true
100+
with:
101+
path: tests/workflows/test-unlock-state
102+
103+
- name: Check terraform-destroy-workspace state locked failure-reason
58104
run: |
59-
if [[ "${{ steps.locked-state.outcome }}" != "failure" ]]; then
105+
if [[ "${{ steps.locked-state-destroy-workspace.outcome }}" != "failure" ]]; then
60106
echo "Apply did not fail correctly"
61107
exit 1
62108
fi
63109
64-
if [[ "${{ steps.locked-state.outputs.failure-reason }}" != "state-locked" ]]; then
110+
if [[ "${{ steps.locked-state-destroy-workspace.outputs.failure-reason }}" != "state-locked" ]]; then
65111
echo "::error:: failure-reason not set correctly"
66112
exit 1
67113
fi
68114
69-
echo '"${{ steps.locked-state.outputs.lock-info }}"'
115+
echo '"${{ steps.locked-state-destroy-workspace.outputs.lock-info }}"'
70116
71-
echo 'Lock id is ${{ fromJson(steps.locked-state.outputs.lock-info).ID }}'
117+
echo 'Lock id is ${{ fromJson(steps.locked-state-destroy-workspace.outputs.lock-info).ID }}'
72118
73119
- name: Unlock the state
74120
uses: ./terraform-unlock-state
75121
continue-on-error: true
76122
with:
77123
path: tests/workflows/test-unlock-state
78-
lock_id: ${{ fromJson(steps.locked-state.outputs.lock-info).ID }}
124+
lock_id: ${{ fromJson(steps.locked-state-apply.outputs.lock-info).ID }}
79125

80126
- name: Check state is not locked
81127
uses: ./terraform-apply

0 commit comments

Comments
 (0)