add specs for ServerExecutor#report=, project= and expiration scheduling
This commit is contained in:
parent
48572f6875
commit
5b364ea41b
@ -40,7 +40,7 @@ module Devops
|
||||
before_deploy :add_run_list_to_deploy_info
|
||||
|
||||
|
||||
attr_accessor :server, :deploy_env
|
||||
attr_accessor :server, :deploy_env, :report, :project
|
||||
|
||||
def initialize server, out, options={}
|
||||
if server
|
||||
@ -65,14 +65,6 @@ module Devops
|
||||
self.class.error_code(symbolic_code)
|
||||
end
|
||||
|
||||
def report= r
|
||||
@report = r
|
||||
end
|
||||
|
||||
def project= p
|
||||
@project = p
|
||||
end
|
||||
|
||||
def create_server_object options
|
||||
Devops::Model::Server.new({
|
||||
"project" => @project.id,
|
||||
|
||||
@ -38,6 +38,20 @@ RSpec.describe Devops::Executor::ServerExecutor, type: :executor, stubbed_connec
|
||||
end
|
||||
|
||||
|
||||
describe '#report=' do
|
||||
it 'sets report instance variable' do
|
||||
executor.report= 'foo'
|
||||
expect(executor).to have_instance_variable_value(:report, 'foo')
|
||||
end
|
||||
end
|
||||
|
||||
describe '#project=' do
|
||||
it 'sets project instance variable' do
|
||||
executor.project= 'foo'
|
||||
expect(executor).to have_instance_variable_value(:project, 'foo')
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
describe '.symbolic_error_code' do
|
||||
it 'returns symbol given an integer' do
|
||||
@ -125,7 +139,15 @@ RSpec.describe Devops::Executor::ServerExecutor, type: :executor, stubbed_connec
|
||||
end
|
||||
|
||||
it 'schedules expiration for server' do
|
||||
expect(executor).to receive(:schedule_expiration).with(an_instance_of(Devops::Model::Server))
|
||||
deploy_env.expires = '2m'
|
||||
allow(DeleteServerWorker).to receive(:perform_in)
|
||||
expect(DeleteServerWorker).to receive(:perform_in).with(120, {server_chef_node_name: 'node_name'})
|
||||
subject
|
||||
end
|
||||
|
||||
it "doesn't schedule expiration if deploy_env.expires is nil" do
|
||||
deploy_env.expires = nil
|
||||
expect(DeleteServerWorker).not_to receive(:perform_in)
|
||||
subject
|
||||
end
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user