Skip to content

Commit

Permalink
Fix some Chef warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
zuazo committed Feb 18, 2017
1 parent 9a6ea3a commit 816f346
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions test/test_chef_handler_sns.rb
Expand Up @@ -277,7 +277,7 @@ def config

it 'publishes messages if node["opsworks"]["activity"] matches allowed '\
'acvities' do
node.set['opsworks']['activity'] = 'deploy'
node.override['opsworks']['activity'] = 'deploy'
config[:filter_opsworks_activity] = %w(deploy setup)

fake_sns.expects(:publish).once
Expand All @@ -286,7 +286,7 @@ def config

it 'does not publish messages if node["opsworks"]["activity"] differs '\
'from allowed acvities' do
node.set['opsworks']['activity'] = 'configure'
node.override['opsworks']['activity'] = 'configure'
config[:filter_opsworks_activity] = %w(deploy setup)

fake_sns.expects(:publish).never
Expand Down
16 changes: 9 additions & 7 deletions test/test_chef_handler_sns_config_ohai.rb
Expand Up @@ -23,7 +23,7 @@
let(:node) do
Chef::Node.new.tap do |node|
node.name('test')
node.set['ec2'] = {
node.override['ec2'] = {
'placement_availability_zone' => 'region1a',
'iam' => {
'security-credentials' => {
Expand All @@ -38,20 +38,22 @@
end
end
let(:config) { Chef::Handler::Sns::Config::Ohai.new(node) }
let(:node_set_iam_roles) { node.set['ec2']['iam']['security-credentials'] }
let(:node_override_iam_roles) do
node.override['ec2']['iam']['security-credentials']
end

describe 'read_config' do
it 'reads the region' do
assert_equal 'region1', config.region
end

it 'does not read the region when not set' do
node.set['ec2']['placement_availability_zone'] = nil
node.override['ec2']['placement_availability_zone'] = nil
assert_nil config.region
end

it 'does not read the credentials when has not IAM role' do
node.set['ec2'] = {}
node.override['ec2'] = {}
assert_nil config.access_key
end

Expand All @@ -60,7 +62,7 @@
end

it 'does not read the access_key when not set' do
node_set_iam_roles['iam-role1']['AccessKeyId'] = nil
node_override_iam_roles['iam-role1']['AccessKeyId'] = nil
assert_nil config.access_key
end

Expand All @@ -69,7 +71,7 @@
end

it 'does not read the secret_key when not set' do
node_set_iam_roles['iam-role1']['SecretAccessKey'] = nil
node_override_iam_roles['iam-role1']['SecretAccessKey'] = nil
assert_nil config.secret_key
end

Expand All @@ -78,7 +80,7 @@
end

it 'does not read the security token when not set' do
node_set_iam_roles['iam-role1']['Token'] = nil
node_override_iam_roles['iam-role1']['Token'] = nil
assert_nil config.token
end
end
Expand Down

0 comments on commit 816f346

Please sign in to comment.