Skip to content

Commit

Permalink
Merge pull request #1074 from objectverbobject/BKR-451
Browse files Browse the repository at this point in the history
(BKR-451) Fix broken logger warnings
  • Loading branch information
kevpl committed Mar 2, 2016
2 parents 0dc2537 + f998bba commit c910267
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/beaker/host/unix/pkg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def deploy_apt_repo(path, name, version)
codename = self['platform'].codename

if codename.nil?
@logger.warning "Could not determine codename for debian platform #{self['platform']}. Skipping deployment of repo #{name}"
@logger.warn "Could not determine codename for debian platform #{self['platform']}. Skipping deployment of repo #{name}"
return
end

Expand Down Expand Up @@ -248,7 +248,7 @@ def deploy_zyp_repo(path, name, version)
# params
def deploy_package_repo(path, name, version)
if not File.exists? path
@logger.warning "Was asked to deploy package repository from #{path}, but it doesn't exist!"
@logger.warn "Was asked to deploy package repository from #{path}, but it doesn't exist!"
return
end

Expand Down
55 changes: 54 additions & 1 deletion spec/beaker/host/unix/pkg_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,61 @@ def exec
let (:logger) { double( 'logger' ).as_null_object }
let (:instance) { UnixPkgTest.new(opts, logger) }

context "check_for_package" do
context 'Package deployment tests' do
path = '/some/file/path'
name = 'package_name'
version = '1.0.0'

describe '#deploy_package_repo' do

it 'returns a warning if there is no file at the path specified' do
expect(logger).to receive(:warn)
allow(File).to receive(:exists?).with(path).and_return(false)
instance.deploy_package_repo(path,name,version)
end

it 'calls #deploy_apt_repo for debian systems' do
@opts = {'platform' => 'ubuntu-is-me'}
expect(instance).to receive(:deploy_apt_repo)
allow(File).to receive(:exists?).with(path).and_return(true)
instance.deploy_package_repo(path,name,version)
end

it 'calls #deploy_yum_repo for el systems' do
@opts = {'platform' => 'el-is-me'}
expect(instance).to receive(:deploy_yum_repo)
allow(File).to receive(:exists?).with(path).and_return(true)
instance.deploy_package_repo(path,name,version)
end

it 'calls #deploy_zyp_repo for sles systems' do
@opts = {'platform' => 'sles-is-me'}
expect(instance).to receive(:deploy_zyp_repo)
allow(File).to receive(:exists?).with(path).and_return(true)
instance.deploy_package_repo(path,name,version)
end

it 'raises an error for unsupported systems' do
@opts = {'platform' => 'windows-is-me'}
allow(File).to receive(:exists?).with(path).and_return(true)
expect{instance.deploy_package_repo(path,name,version)}.to raise_error(RuntimeError)
end
end

describe '#deploy_apt_repo' do

it 'warns and exits when no codename exists for the debian platform' do
@opts = {'platform' => 'ubuntu-is-me'}
expect(logger).to receive(:warn)
allow(@opts['platform']).to receive(:codename).and_return(nil)
expect(instance).to receive(:deploy_apt_repo).and_return(instance.deploy_apt_repo(path,name,version))
allow(File).to receive(:exists?).with(path).and_return(true)
instance.deploy_package_repo(path,name,version)
end
end
end

context "check_for_package" do
it "checks correctly on sles" do
@opts = {'platform' => 'sles-is-me'}
pkg = 'sles_package'
Expand Down

0 comments on commit c910267

Please sign in to comment.