Skip to content

Commit

Permalink
Merge pull request #5191 from bgeuken/factory_plugin/tests
Browse files Browse the repository at this point in the history
Factory plugin/tests
  • Loading branch information
bgeuken committed Jun 26, 2018
2 parents a4df002 + 62c6e8f commit 74fbace
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module ObsFactory
# this is not a Factory pattern, this is for openSUSE:Factory :/
class DistributionStrategyFactory
include ActiveModel::Model

attr_accessor :project

# String to pass as version to filter the openQA jobs
Expand Down
8 changes: 2 additions & 6 deletions src/api/app/models/obs_factory/distribution_strategy_sle15.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,8 @@ def test_dvd_prefix
end

def sp_version(name)
if name.start_with? 'SUSE:SLE-15:GA'
nil
else
match = name.match(/SUSE:SLE-15-(.*):GA/)
match[1]
end
/SUSE:SLE-15-(?<service_pack>.*):GA/ =~ name
service_pack
end

# Name of the ISO file by the given staging project tracked on openqa
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require 'rails_helper'

RSpec.describe ObsFactory::DistributionStrategySLE15 do
let(:stategy) { ObsFactory::DistributionStrategySLE15.new(project: create(:project)) }

describe '#sp_version' do
it 'returns the correct service pack version' do
expect(stategy.sp_version('SUSE:SLE-15:GA')).to be_nil
expect(stategy.sp_version('SUSE:SLE-15-SP4:GA')).to eq('SP4')
end
end
end

0 comments on commit 74fbace

Please sign in to comment.