Skip to content

Commit

Permalink
[ci] Add specs for Kiwi::Image#to_xml
Browse files Browse the repository at this point in the history
does not alter the xml to decrease the resulting diff.
  • Loading branch information
ChrisBr committed Oct 16, 2017
1 parent 2ff274e commit ff420c0
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/api/spec/models/kiwi/image_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,44 @@

it { expect(subject.to_xml).to be_nil }
end

context 'with a kiwi file with packages and repositories' do
let(:package) { create(:package) }
let(:kiwi_image) { Kiwi::Image.build_from_xml(kiwi_xml, 'some_md5') }
subject { Nokogiri::XML::DocumentFragment.parse(kiwi_image.to_xml) }

before do
allow(package).to receive(:kiwi_image_file).and_return('config.kiwi')
allow(package).to receive(:source_file).and_return(kiwi_xml)
kiwi_image.package = package
kiwi_image.save
end

it { expect(subject.children[2].children[3].name).to eq('packages') }
it { expect(subject.children[2].children[3].attributes['type'].value).to eq('image') }
it { expect(subject.children[2].children[7].name).to eq('repository') }
it { expect(subject.children[2].children[9].name).to eq('repository') }
it { expect(subject.children[2].children[11].name).to eq('repository') }
it { expect(subject.children[2].children[13].name).to eq('repository') }
end

context 'with a kiwi file without packages and repositories' do
let(:package) { create(:package) }
let(:kiwi_image) { Kiwi::Image.build_from_xml(Kiwi::Image::DEFAULT_KIWI_BODY, 'some_md5') }
subject { Nokogiri::XML::DocumentFragment.parse(kiwi_image.to_xml) }

before do
allow(package).to receive(:kiwi_image_file).and_return('config.kiwi')
allow(package).to receive(:source_file).and_return(Kiwi::Image::DEFAULT_KIWI_BODY)
kiwi_image.package = package
kiwi_image.package_groups << create(:kiwi_package_group_non_empty, kiwi_type: 'image')
kiwi_image.repositories << create(:kiwi_repository)
kiwi_image.save
end

it { expect(subject.children[2].children[5].name).to eq('packages') }
it { expect(subject.children[2].children[7].name).to eq('repository') }
end
end

describe '.write_to_backend' do
Expand Down

0 comments on commit ff420c0

Please sign in to comment.