Skip to content
This repository was archived by the owner on Jun 2, 2021. It is now read-only.

Commit 9a198a1

Browse files
v3(tests): assert job still polling last operation tests
[#174878594](https://www.pivotaltracker.com/story/show/174878594)
1 parent ce1fe8b commit 9a198a1

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

spec/support/shared_examples/request/bindings_orphan_mitigation.rb

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,10 @@
105105
to_return(status: 200, body: 'this is not json')
106106
end
107107

108-
it 'fails the job and does not perform orphan mitigation' do
108+
it 'retries the job and does not perform orphan mitigation' do
109109
execute_all_jobs(expected_successes: 1, expected_failures: 0)
110110

111+
assert_polling_job(binding, job)
111112
assert_no_orphan_mitigation_performed(plan_id, offering_id)
112113
end
113114
end
@@ -121,9 +122,10 @@
121122
to_return(status: 410, body: '{}')
122123
end
123124

124-
it 'retries and does not perform orphan mitigation' do
125+
it 'retries the job does not perform orphan mitigation' do
125126
execute_all_jobs(expected_successes: 1, expected_failures: 0)
126127

128+
assert_polling_job(binding, job)
127129
assert_no_orphan_mitigation_performed(plan_id, offering_id)
128130
end
129131
end
@@ -139,6 +141,7 @@
139141
it 'retries and does not perform orphan mitigation' do
140142
execute_all_jobs(expected_successes: 1, expected_failures: 0)
141143

144+
assert_polling_job(binding, job)
142145
assert_no_orphan_mitigation_performed(plan_id, offering_id)
143146
end
144147
end
@@ -151,9 +154,10 @@
151154
to_return(status: 400, body: '{}')
152155
end
153156

154-
it 'retries and does not perform orphan mitigation' do
157+
it 'fails the job and does not perform orphan mitigation' do
155158
execute_all_jobs(expected_successes: 0, expected_failures: 1)
156159

160+
assert_failed_job(binding, job)
157161
assert_no_orphan_mitigation_performed(plan_id, offering_id)
158162
end
159163
end
@@ -265,6 +269,13 @@ def assert_failed_job(binding, job)
265269
expect(job.state).to eq(VCAP::CloudController::PollableJobModel::FAILED_STATE)
266270
end
267271

272+
def assert_polling_job(binding, job)
273+
binding.reload
274+
expect(binding.last_operation.type).to eq('create')
275+
expect(binding.last_operation.state).to eq('in progress')
276+
expect(job.state).to eq(VCAP::CloudController::PollableJobModel::POLLING_STATE)
277+
end
278+
268279
def assert_orphan_mitigation_performed(plan_id, offering_id)
269280
expect(delete_request(plan_id, offering_id)).to have_been_made.once
270281
end

0 commit comments

Comments
 (0)