Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle semver build metadata/pre-release info #134

Merged
merged 1 commit into from
Jun 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/k8s/transport.rb
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ def version

# @return [Boolean] true if delete options should be sent as bode of the DELETE request
def need_delete_body?
@need_delete_body ||= Gem::Version.new(version.gitVersion.match(/v*(.*)/)[1]) < DELETE_OPTS_BODY_VERSION_MIN
@need_delete_body ||= Gem::Version.new(version.gitVersion.match(/^v*((\d|\.)*)/)[1]) < DELETE_OPTS_BODY_VERSION_MIN
end

# @param path [Array<String>] @see #path
Expand Down
27 changes: 27 additions & 0 deletions spec/k8s/transport_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -675,4 +675,31 @@
end
end
end

describe '#need_delete_body?' do
it 'returns true if older than 1.11' do
allow(subject).to receive(:version).and_return(double(:version, gitVersion: '1.10.4'))
expect(subject.need_delete_body?).to be_truthy
end

it 'returns false if 1.11.0' do
allow(subject).to receive(:version).and_return(double(:version, gitVersion: '1.11.0'))
expect(subject.need_delete_body?).to be_falsey
end

it 'returns false newer than 1.11.0' do
allow(subject).to receive(:version).and_return(double(:version, gitVersion: '1.11.1'))
expect(subject.need_delete_body?).to be_falsey
end

it 'handles semver build metadata' do
allow(subject).to receive(:version).and_return(double(:version, gitVersion: '1.10.1+asdasd'))
expect(subject.need_delete_body?).to be_truthy
end

it 'handles semver pre-release' do
allow(subject).to receive(:version).and_return(double(:version, gitVersion: '1.10.1-rc.1'))
expect(subject.need_delete_body?).to be_truthy
end
end
end