-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: trim long versions on can-i-deploy formatting (#91)
- Loading branch information
Showing
2 changed files
with
64 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
spec/lib/pact_broker/client/matrix/abbreviate_version_number_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
require 'pact_broker/client/matrix/abbreviate_version_number' | ||
|
||
module PactBroker | ||
module Client | ||
describe Matrix::AbbreviateVersionNumber do | ||
describe '.call' do | ||
subject(:result) { described_class.call(version) } | ||
|
||
context 'when version is nil' do | ||
let(:version) { nil } | ||
it { is_expected.to be_nil } | ||
end | ||
|
||
context 'when version is git sha' do | ||
let(:version) { '182f9c6e4d7a5779c4507cb8b3e505ac927d0394' } | ||
it { is_expected.to eq('182f9c6...') } | ||
end | ||
|
||
context 'when version is too long' do | ||
let(:version) { '182f9c6e4d7a5779c4507cb8b3e505ac927d0394' * 2 } | ||
it { is_expected.to eq(version[0...60] + '...') } | ||
end | ||
|
||
context 'when the version is something unknown and fits max length' do | ||
let(:version) { '123' } | ||
it { is_expected.to eq('123') } | ||
end | ||
|
||
context 'when version is embedded into semantic version v1' do | ||
let(:version) { 'v1.3.4+182f9c6e4d7a5779c4507cb8b3e505ac927d0394' } | ||
it { is_expected.to eq('v1.3.4+182f9c6...') } | ||
end | ||
|
||
context 'when version is embedded into semantic version v2' do | ||
let(:version) { '1.3.4(182f9c6e4d7a5779c4507cb8b3e505ac927d0394)' } | ||
it { is_expected.to eq('1.3.4(182f9c6...)') } | ||
end | ||
end | ||
end | ||
end | ||
end |