Skip to content

Commit

Permalink
SLE12 has different isbase key, so we should conform
Browse files Browse the repository at this point in the history
Either that can be `isbase='1'` either `isbase='true'`
  • Loading branch information
kalabiyau committed Feb 21, 2014
1 parent 0f92bcd commit 9cbd8cd
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/suse/connect/zypper.rb
Expand Up @@ -19,7 +19,7 @@ def installed_products
end

def base_product
base = installed_products.select {|product| product[:isbase] == '1' }.first
base = installed_products.select {|product| %w{1 true}.include?(product[:isbase]) }.first
raise CannotDetectBaseProduct unless base
base
end
Expand Down
58 changes: 54 additions & 4 deletions spec/connect/zyppper_spec.rb
Expand Up @@ -10,10 +10,60 @@

describe '.installed_products' do

it 'returns valid list of products based on proper XML' do
xml = File.read('spec/fixtures/products_valid.xml')
Object.should_receive(:'`').with(include 'zypper').and_return(xml)
subject.installed_products.first[:name].should eq 'SUSE_SLES'
context :sle11 do
context :sp3 do

let(:xml) { File.read('spec/fixtures/product_valid_sle11sp3.xml') }

before do
Object.should_receive(:'`').with(include 'zypper').and_return(xml)
end

it 'returns valid list of products based on proper XML' do
subject.installed_products.first[:name].should eq 'SUSE_SLES'
end

it 'returns valid version' do
subject.installed_products.first[:version].should eq '11.3'
end

it 'returns valid arch' do
subject.installed_products.first[:arch].should eq 'x86_64'
end

it 'returns proper base product' do
subject.base_product[:name].should eq 'SUSE_SLES'
end

end
end

context :sle12 do
context :sp0 do

let(:xml) { File.read('spec/fixtures/product_valid_sle12sp0.xml') }

before do
Object.should_receive(:'`').with(include 'zypper').and_return(xml)
end

it 'returns valid name' do
subject.installed_products.first[:name].should eq 'SLES'
end

it 'returns valid version' do
subject.installed_products.first[:version].should eq '12'
end

it 'returns valid arch' do
subject.installed_products.first[:arch].should eq 'x86_64'
end

it 'returns proper base product' do
puts subject.base_product[:name].should eq 'SLES'
end

end
end

end
Expand Down
Expand Up @@ -2,15 +2,17 @@
<stream>
<product-list>
<product name="SUSE_SLES" version="11.3" release="1.138" epoch="0" arch="x86_64" productline="sles" registerrelease="" vendor="SUSE LINUX Products GmbH, Nuernberg, Germany" summary="SUSE Linux Enterprise Server 11 SP3" shortname="SLES11_SP3" flavor="" isbase="1" repo="@System" installed="1">
<description>SUSE Linux Enterprise offers a comprehensive
<description>
SUSE Linux Enterprise offers a comprehensive
suite of products built on a single code base.
The platform addresses business needs from
the smallest thin-client devices to the world’s
most powerful high-performance computing
and mainframe servers. SUSE Linux Enterprise
offers common management tools and technology
certifications across the platform, and
each product is enterprise-class.</description>
each product is enterprise-class.
</description>
</product>
</product-list>
</stream>
19 changes: 19 additions & 0 deletions spec/fixtures/product_valid_sle12sp0.xml
@@ -0,0 +1,19 @@
<?xml version='1.0'?>
<stream>
<product-list>
<product name="SLES" version="12" release="" epoch="0" arch="x86_64" vendor="SUSE" summary="SUSE Linux Enterprise Server 12" repo="@System" productline="sles" registerrelease="" shortname="SLES12" flavor="DVD" isbase="true" installed="true">
<endoflife time_t="1220070400" text="2008-01-01T01:00:00+01"/>
<description>
SUSE Linux Enterprise offers a comprehensive
suite of products built on a single code base.
The platform addresses business needs from
the smallest thin-client devices to the world’s
most powerful high-performance computing
and mainframe servers. SUSE Linux Enterprise
offers common management tools and technology
certifications across the platform, and
each product is enterprise-class.
</description>
</product>
</product-list>
</stream>

0 comments on commit 9cbd8cd

Please sign in to comment.