diff options
author | João Cunha <j.a.cunha@gmail.com> | 2019-09-13 12:17:02 +0100 |
---|---|---|
committer | João Cunha <j.a.cunha@gmail.com> | 2019-09-13 12:17:02 +0100 |
commit | 7bb8065c14908a69aa8b9cd9b0253b0bd85aeb9d (patch) | |
tree | 96e572bdbdb9527ec25b91f9fa3d3f5cc2222814 | |
parent | cba7959bafed6b963b6bfd8e794e6257e2ae95dd (diff) | |
download | gitlab-ce-feature/advanced-delete-k8s-resources.tar.gz |
Make the reschedule worker test more explicitfeature/advanced-delete-k8s-resources
-rw-r--r-- | spec/workers/cluster_remove_worker_spec.rb | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/spec/workers/cluster_remove_worker_spec.rb b/spec/workers/cluster_remove_worker_spec.rb index a12c40f95fe..e78181ac045 100644 --- a/spec/workers/cluster_remove_worker_spec.rb +++ b/spec/workers/cluster_remove_worker_spec.rb @@ -71,19 +71,30 @@ describe ClusterRemoveWorker do end context 'when cluster has uninstallable applications' do - context 'has applications with dependencies' do - before do + before do + allow(described_class) + .to receive(:perform_in) + .with(20.seconds, cluster.id, 1) + end + + shared_examples 'reschedules itself' do + it 'reschedules itself' do expect(described_class) .to receive(:perform_in) .with(20.seconds, cluster.id, 1) + + subject end + end + context 'has applications with dependencies' do let!(:helm) { create(:clusters_applications_helm, :installed, cluster: cluster) } let!(:ingress) { create(:clusters_applications_ingress, :installed, cluster: cluster) } let!(:cert_manager) { create(:clusters_applications_cert_manager, :installed, cluster: cluster) } let!(:jupyter) { create(:clusters_applications_jupyter, :installed, cluster: cluster) } it_behaves_like 'removing cluster' + it_behaves_like 'reschedules itself' it 'only uninstalls apps that are not dependencies for other installed apps' do expect(Clusters::Applications::UninstallService) @@ -112,24 +123,20 @@ describe ClusterRemoveWorker do subject end end - end - context 'when applications are still uninstalling/scheduled' do - after do - subject - end + context 'when applications are still uninstalling/scheduled' do + let!(:helm) { create(:clusters_applications_helm, :installed, cluster: cluster) } + let!(:ingress) { create(:clusters_applications_ingress, :scheduled, cluster: cluster) } + let!(:runner) { create(:clusters_applications_runner, :uninstalling, cluster: cluster) } - let!(:helm) { create(:clusters_applications_helm, :installed, cluster: cluster) } - let!(:ingress) { create(:clusters_applications_ingress, :scheduled, cluster: cluster) } - let!(:runner) { create(:clusters_applications_runner, :uninstalling, cluster: cluster) } + it_behaves_like 'reschedules itself' - it 'reschedules the worker to proceed the uninstallation later' do - expect(Clusters::Applications::UninstallService) - .not_to receive(:new) + it 'does not call the uninstallation service' do + expect(Clusters::Applications::UninstallService) + .not_to receive(:new) - expect(described_class) - .to receive(:perform_in) - .with(20.seconds, cluster.id, 1) + subject + end end end |