diff options
author | Thong Kuah <tkuah@gitlab.com> | 2019-04-12 08:28:06 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2019-04-30 08:55:11 +0300 |
commit | 3c8df0c944f0b23f9ee8b6b08a0a355b00456dd9 (patch) | |
tree | e17c11245edf069af55f97c3b9df1544c33db57a /spec | |
parent | 938e90f47288901790a96c50a8c0dfa2b7eab137 (diff) |
Destroy app on successful uninstallation
Rescue and put into :uninstall_errored if something goes wrong while
destroying, which can happen. I think it is safe to expose the full
error message from the destroy error.
Remove the :uninstalled state as no longer used.
Diffstat (limited to 'spec')
3 files changed, 20 insertions, 18 deletions
diff --git a/spec/factories/clusters/applications/helm.rb b/spec/factories/clusters/applications/helm.rb index ac230950fce..22a0888947e 100644 --- a/spec/factories/clusters/applications/helm.rb +++ b/spec/factories/clusters/applications/helm.rb @@ -49,10 +49,6 @@ FactoryBot.define do status_reason 'something went wrong' end - trait :uninstalled do - status 9 - end - trait :timeouted do installing updated_at { ClusterWaitForAppInstallationWorker::TIMEOUT.ago } diff --git a/spec/services/clusters/applications/check_uninstall_progress_service_spec.rb b/spec/services/clusters/applications/check_uninstall_progress_service_spec.rb index ccae7fd133f..084f29d9d2d 100644 --- a/spec/services/clusters/applications/check_uninstall_progress_service_spec.rb +++ b/spec/services/clusters/applications/check_uninstall_progress_service_spec.rb @@ -56,13 +56,30 @@ describe Clusters::Applications::CheckUninstallProgressService do service.execute end - it 'make the application installed' do + it 'destroys the application' do expect(worker_class).not_to receive(:perform_in) service.execute + expect(application).to be_destroyed + end + + context 'an error occurs while destroying' do + before do + expect(application).to receive(:destroy!).once.and_raise("destroy failed") + end + + it 'still removes the installation POD' do + expect(service).to receive(:remove_installation_pod).once - expect(application).to be_uninstalled - expect(application.status_reason).to be_nil + service.execute + end + + it 'makes the application uninstall_errored' do + service.execute + + expect(application).to be_uninstall_errored + expect(application.status_reason).to eq('Application uninstalled but failed to destroy: destroy failed') + end end end diff --git a/spec/support/shared_examples/models/cluster_application_status_shared_examples.rb b/spec/support/shared_examples/models/cluster_application_status_shared_examples.rb index c56b148cb8c..233b9db8f7b 100644 --- a/spec/support/shared_examples/models/cluster_application_status_shared_examples.rb +++ b/spec/support/shared_examples/models/cluster_application_status_shared_examples.rb @@ -192,16 +192,6 @@ shared_examples 'cluster application status specs' do |application_name| expect(subject).to be_uninstalling end end - - describe '#make_uninstalled' do - subject { create(application_name, :uninstalling) } - - it 'is uninstalled' do - subject.make_uninstalled! - - expect(subject).to be_uninstalled - end - end end describe '#available?' do @@ -219,7 +209,6 @@ shared_examples 'cluster application status specs' do |application_name| :update_errored | false :uninstalling | false :uninstall_errored | false - :uninstalled | false :timeouted | false end |