Skip to content

Commit

Permalink
Add unit spec
Browse files Browse the repository at this point in the history
Signed-off-by: NAshwini <ashwini.nehate@msystechnologies.com>
  • Loading branch information
NAshwini committed Jul 3, 2018
1 parent add0c23 commit 0dd2b2d
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions spec/unit/report/fetcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

require 'spec_helper'
require_relative '../../../files/default/vendor/chef-server/fetcher'
require "byebug"

describe ChefServer::Fetcher do
let(:mynode) { Chef::Node.new }
Expand All @@ -33,6 +34,9 @@
let(:profile_hash_target) {
'/organizations/org/owners/user/compliance/linux-baseline/version/2.1.0/tar'
}
let(:non_profile_url){
'http://127.0.0.1:8889/organizations/org/owners/user/compliance/linux-baseline/version/2.1.0/tar'
}

context 'when target is a string' do
before :each do
Expand Down Expand Up @@ -70,4 +74,28 @@
expect(res.target.request_uri).to eq(profile_hash_target)
end
end

context 'when profile not found' do
before :each do
Chef::Config[:verify_api_cert] = false
Chef::Config[:ssl_verify_mode] = :verify_none
allow(Chef).to receive(:node).and_return(mynode)
end

it 'should raise error' do
myproc = proc {
config = {
'server_type' => 'automate',
'automate' => {
'ent' => 'my_ent',
'token_type' => 'dctoken',
},
'profile' => ['admin', 'linux-baseline', '2.0']
}

Fetchers::Url.new('non_profile_url', config).send(:http_opts)
}
expect {myproc.call}.to raise_error(RuntimeError)
end
end
end

0 comments on commit 0dd2b2d

Please sign in to comment.