Commit 76f95b66 authored by Seth Chisamore's avatar Seth Chisamore

Rename `#metadata_for` to `#metadata_properties_for`

We’ll also move generation of the `build.*` properties in this new 
method.
parent 3e59997f
......@@ -38,10 +38,7 @@ module Omnibus
artifact_for(package).upload(
repository,
remote_path_for(package),
metadata_for(package).merge(
'build.name' => package.metadata[:name],
'build.number' => package.metadata[:version],
),
metadata_properties_for(package),
)
end
rescue Artifactory::Error::HTTPError => e
......@@ -188,8 +185,8 @@ module Omnibus
#
# @return [Hash<String, String>]
#
def metadata_for(package)
{
def metadata_properties_for(package)
metadata = {
'omnibus.project' => package.metadata[:name],
'omnibus.platform' => package.metadata[:platform],
'omnibus.platform_version' => package.metadata[:platform_version],
......@@ -201,6 +198,12 @@ module Omnibus
'omnibus.sha256' => package.metadata[:sha256],
'omnibus.sha512' => package.metadata[:sha512],
}
metadata.merge!(
'build.name' => package.metadata[:name],
'build.number' => package.metadata[:version],
) if build_record?
metadata
end
end
#
......
......@@ -3,8 +3,8 @@ require 'spec_helper'
module Omnibus
describe ArtifactoryPublisher do
let(:path) { '/path/to/files/*.deb' }
let(:repository) { 'REPO' }
let(:build_record) { true }
let(:package) do
double(Package,
......@@ -27,6 +27,8 @@ module Omnibus
platform_version: '14.04',
arch: 'x86_64',
sha1: 'SHA1',
sha256: 'SHA256',
sha512: 'SHA512',
md5: 'ABCDEF123456',
)
end
......@@ -44,7 +46,7 @@ module Omnibus
allow(build).to receive(:save)
end
subject { described_class.new(path, repository: repository) }
subject { described_class.new(path, repository: repository, build_record: build_record) }
describe '#publish' do
before do
......@@ -119,5 +121,40 @@ module Omnibus
end
end
end
describe '#metadata_properties_for' do
let(:transformed_metadata_values) do
{
"omnibus.architecture" => "x86_64",
"omnibus.iteration" => 1,
"omnibus.md5" => "ABCDEF123456",
"omnibus.platform" => "ubuntu",
"omnibus.platform_version" => "14.04",
"omnibus.project" => "chef",
"omnibus.sha1" => "SHA1",
"omnibus.sha256" => "SHA256",
"omnibus.sha512" => "SHA512",
"omnibus.version" => "11.0.6",
}
end
let(:build_values) do
{
"build.name" => "chef",
"build.number" => "11.0.6",
}
end
it 'returns the transformed package metadata values' do
expect(subject.send(:metadata_properties_for, package)).to include(transformed_metadata_values.merge(build_values))
end
context ':build_record is false' do
let(:build_record) { false }
it 'does not include `build.*` values' do
expect(subject.send(:metadata_properties_for, package)).to include(transformed_metadata_values)
expect(subject.send(:metadata_properties_for, package)).to_not include(build_values)
end
end
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment