2013-05-08 05:19:51 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-07-10 14:24:02 +00:00
|
|
|
describe 'Gitlab::VersionInfo' do
|
2013-05-08 05:19:51 +00:00
|
|
|
before do
|
|
|
|
@unknown = Gitlab::VersionInfo.new
|
|
|
|
@v0_0_1 = Gitlab::VersionInfo.new(0, 0, 1)
|
|
|
|
@v0_1_0 = Gitlab::VersionInfo.new(0, 1, 0)
|
|
|
|
@v1_0_0 = Gitlab::VersionInfo.new(1, 0, 0)
|
|
|
|
@v1_0_1 = Gitlab::VersionInfo.new(1, 0, 1)
|
|
|
|
@v1_1_0 = Gitlab::VersionInfo.new(1, 1, 0)
|
|
|
|
@v2_0_0 = Gitlab::VersionInfo.new(2, 0, 0)
|
|
|
|
end
|
|
|
|
|
|
|
|
context '>' do
|
2015-02-12 18:17:35 +00:00
|
|
|
it { expect(@v2_0_0).to be > @v1_1_0 }
|
|
|
|
it { expect(@v1_1_0).to be > @v1_0_1 }
|
|
|
|
it { expect(@v1_0_1).to be > @v1_0_0 }
|
|
|
|
it { expect(@v1_0_0).to be > @v0_1_0 }
|
|
|
|
it { expect(@v0_1_0).to be > @v0_0_1 }
|
2013-05-08 05:19:51 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context '>=' do
|
2015-02-12 18:17:35 +00:00
|
|
|
it { expect(@v2_0_0).to be >= Gitlab::VersionInfo.new(2, 0, 0) }
|
|
|
|
it { expect(@v2_0_0).to be >= @v1_1_0 }
|
2013-05-08 05:19:51 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context '<' do
|
2015-02-12 18:17:35 +00:00
|
|
|
it { expect(@v0_0_1).to be < @v0_1_0 }
|
|
|
|
it { expect(@v0_1_0).to be < @v1_0_0 }
|
|
|
|
it { expect(@v1_0_0).to be < @v1_0_1 }
|
|
|
|
it { expect(@v1_0_1).to be < @v1_1_0 }
|
|
|
|
it { expect(@v1_1_0).to be < @v2_0_0 }
|
2013-05-08 05:19:51 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context '<=' do
|
2015-02-12 18:17:35 +00:00
|
|
|
it { expect(@v0_0_1).to be <= Gitlab::VersionInfo.new(0, 0, 1) }
|
|
|
|
it { expect(@v0_0_1).to be <= @v0_1_0 }
|
2013-05-08 05:19:51 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context '==' do
|
2015-02-12 18:17:35 +00:00
|
|
|
it { expect(@v0_0_1).to eq(Gitlab::VersionInfo.new(0, 0, 1)) }
|
|
|
|
it { expect(@v0_1_0).to eq(Gitlab::VersionInfo.new(0, 1, 0)) }
|
|
|
|
it { expect(@v1_0_0).to eq(Gitlab::VersionInfo.new(1, 0, 0)) }
|
2013-05-08 05:19:51 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context '!=' do
|
2015-02-12 18:17:35 +00:00
|
|
|
it { expect(@v0_0_1).not_to eq(@v0_1_0) }
|
2013-05-08 05:19:51 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'unknown' do
|
2015-02-12 18:17:35 +00:00
|
|
|
it { expect(@unknown).not_to be @v0_0_1 }
|
|
|
|
it { expect(@unknown).not_to be Gitlab::VersionInfo.new }
|
2017-08-09 09:52:22 +00:00
|
|
|
it { expect {@unknown > @v0_0_1}.to raise_error(ArgumentError) }
|
|
|
|
it { expect {@unknown < @v0_0_1}.to raise_error(ArgumentError) }
|
2013-05-08 05:19:51 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'parse' do
|
2015-02-12 18:17:35 +00:00
|
|
|
it { expect(Gitlab::VersionInfo.parse("1.0.0")).to eq(@v1_0_0) }
|
|
|
|
it { expect(Gitlab::VersionInfo.parse("1.0.0.1")).to eq(@v1_0_0) }
|
2018-09-20 16:10:41 +00:00
|
|
|
it { expect(Gitlab::VersionInfo.parse("1.0.0-ee")).to eq(@v1_0_0) }
|
|
|
|
it { expect(Gitlab::VersionInfo.parse("1.0.0-rc1")).to eq(@v1_0_0) }
|
|
|
|
it { expect(Gitlab::VersionInfo.parse("1.0.0-rc1-ee")).to eq(@v1_0_0) }
|
2015-02-12 18:17:35 +00:00
|
|
|
it { expect(Gitlab::VersionInfo.parse("git 1.0.0b1")).to eq(@v1_0_0) }
|
|
|
|
it { expect(Gitlab::VersionInfo.parse("git 1.0b1")).not_to be_valid }
|
2013-05-08 05:19:51 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'to_s' do
|
2015-02-12 18:17:35 +00:00
|
|
|
it { expect(@v1_0_0.to_s).to eq("1.0.0") }
|
|
|
|
it { expect(@unknown.to_s).to eq("Unknown") }
|
2013-05-08 05:19:51 +00:00
|
|
|
end
|
|
|
|
end
|