omnibus 5.4.0 → 5.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -3
- data/CHANGELOG.md +21 -0
- data/Gemfile +8 -5
- data/README.md +3 -1
- data/Rakefile +20 -13
- data/appveyor.yml +4 -3
- data/bin/omnibus +3 -3
- data/features/commands/manifest.feature +19 -5
- data/features/step_definitions/generator_steps.rb +5 -6
- data/features/support/env.rb +4 -4
- data/lib/omnibus/build_version.rb +14 -14
- data/lib/omnibus/build_version_dsl.rb +3 -3
- data/lib/omnibus/builder.rb +50 -61
- data/lib/omnibus/changelog.rb +2 -2
- data/lib/omnibus/changelog_printer.rb +4 -4
- data/lib/omnibus/cleaner.rb +4 -4
- data/lib/omnibus/cli/base.rb +15 -15
- data/lib/omnibus/cli/cache.rb +13 -13
- data/lib/omnibus/cli/changelog.rb +8 -9
- data/lib/omnibus/cli/publish.rb +12 -13
- data/lib/omnibus/cli.rb +26 -27
- data/lib/omnibus/compressor.rb +6 -6
- data/lib/omnibus/compressors/base.rb +7 -2
- data/lib/omnibus/compressors/dmg.rb +12 -12
- data/lib/omnibus/compressors/null.rb +1 -1
- data/lib/omnibus/compressors/tgz.rb +8 -8
- data/lib/omnibus/config.rb +37 -26
- data/lib/omnibus/core_extensions/open_uri.rb +3 -3
- data/lib/omnibus/core_extensions.rb +1 -1
- data/lib/omnibus/digestable.rb +5 -4
- data/lib/omnibus/download_helpers.rb +7 -6
- data/lib/omnibus/exceptions.rb +29 -13
- data/lib/omnibus/fetcher.rb +0 -1
- data/lib/omnibus/fetchers/git_fetcher.rb +7 -7
- data/lib/omnibus/fetchers/net_fetcher.rb +19 -19
- data/lib/omnibus/fetchers/path_fetcher.rb +1 -1
- data/lib/omnibus/file_syncer.rb +3 -3
- data/lib/omnibus/generator.rb +60 -47
- data/lib/omnibus/git_cache.rb +33 -22
- data/lib/omnibus/git_repository.rb +5 -5
- data/lib/omnibus/health_check.rb +122 -119
- data/lib/omnibus/instrumentation.rb +1 -1
- data/lib/omnibus/licensing.rb +348 -60
- data/lib/omnibus/logger.rb +12 -9
- data/lib/omnibus/logging.rb +1 -1
- data/lib/omnibus/manifest.rb +4 -4
- data/lib/omnibus/manifest_diff.rb +6 -7
- data/lib/omnibus/manifest_entry.rb +1 -1
- data/lib/omnibus/metadata.rb +36 -36
- data/lib/omnibus/ohai.rb +6 -7
- data/lib/omnibus/package.rb +1 -1
- data/lib/omnibus/packager.rb +37 -28
- data/lib/omnibus/packagers/appx.rb +86 -0
- data/lib/omnibus/packagers/base.rb +21 -18
- data/lib/omnibus/packagers/bff.rb +22 -24
- data/lib/omnibus/packagers/deb.rb +20 -20
- data/lib/omnibus/packagers/ips.rb +18 -17
- data/lib/omnibus/packagers/makeself.rb +7 -7
- data/lib/omnibus/packagers/msi.rb +38 -193
- data/lib/omnibus/packagers/pkg.rb +16 -16
- data/lib/omnibus/packagers/rpm.rb +53 -54
- data/lib/omnibus/packagers/solaris.rb +14 -14
- data/lib/omnibus/packagers/windows_base.rb +192 -0
- data/lib/omnibus/project.rb +45 -43
- data/lib/omnibus/publisher.rb +3 -3
- data/lib/omnibus/publishers/artifactory_publisher.rb +39 -39
- data/lib/omnibus/publishers/s3_publisher.rb +7 -7
- data/lib/omnibus/reports.rb +10 -10
- data/lib/omnibus/s3_cache.rb +7 -7
- data/lib/omnibus/s3_helpers.rb +8 -7
- data/lib/omnibus/semantic_version.rb +1 -1
- data/lib/omnibus/software.rb +131 -81
- data/lib/omnibus/sugarable.rb +10 -10
- data/lib/omnibus/templating.rb +5 -5
- data/lib/omnibus/thread_pool.rb +1 -1
- data/lib/omnibus/util.rb +5 -5
- data/lib/omnibus/version.rb +1 -1
- data/lib/omnibus.rb +65 -65
- data/omnibus.gemspec +34 -32
- data/resources/appx/AppxManifest.xml.erb +18 -0
- data/resources/appx/assets/clear.png +0 -0
- data/spec/fixtures/licensing/license_scout/snoopy/ruby_bundler-bundler-audit-0.5.0-COPYING.txt +674 -0
- data/spec/fixtures/licensing/license_scout/snoopy/ruby_bundler-inifile-3.0.0-README.md +215 -0
- data/spec/fixtures/licensing/license_scout/snoopy/snoopy-dependency-licenses.json +24 -0
- data/spec/fixtures/licensing/license_scout/zlib/ruby_bundler-inifile-3.0.0-README.md +215 -0
- data/spec/fixtures/licensing/license_scout/zlib/ruby_bundler-mime-types-3.1-Licence.rdoc +25 -0
- data/spec/fixtures/licensing/license_scout/zlib/ruby_bundler-mini_portile2-2.1.0-LICENSE.txt +20 -0
- data/spec/fixtures/licensing/license_scout/zlib/zlib-dependency-licenses.json +32 -0
- data/spec/functional/builder_spec.rb +149 -150
- data/spec/functional/fetchers/git_fetcher_spec.rb +69 -71
- data/spec/functional/fetchers/net_fetcher_spec.rb +79 -79
- data/spec/functional/fetchers/path_fetcher_spec.rb +19 -20
- data/spec/functional/file_syncer_spec.rb +74 -74
- data/spec/functional/licensing_spec.rb +344 -35
- data/spec/functional/templating_spec.rb +17 -17
- data/spec/spec_helper.rb +20 -20
- data/spec/support/examples.rb +21 -15
- data/spec/support/file_helpers.rb +1 -1
- data/spec/support/git_helpers.rb +37 -37
- data/spec/support/matchers.rb +3 -3
- data/spec/support/ohai_helpers.rb +4 -4
- data/spec/support/path_helpers.rb +2 -2
- data/spec/support/shell_helpers.rb +2 -2
- data/spec/unit/build_version_dsl_spec.rb +5 -5
- data/spec/unit/build_version_spec.rb +63 -63
- data/spec/unit/builder_spec.rb +86 -70
- data/spec/unit/changelog_spec.rb +4 -4
- data/spec/unit/changelogprinter_spec.rb +130 -0
- data/spec/unit/cleanroom_spec.rb +11 -11
- data/spec/unit/compressor_spec.rb +16 -16
- data/spec/unit/compressors/base_spec.rb +6 -6
- data/spec/unit/compressors/dmg_spec.rb +76 -76
- data/spec/unit/compressors/null_spec.rb +4 -4
- data/spec/unit/compressors/tgz_spec.rb +20 -20
- data/spec/unit/config_spec.rb +44 -43
- data/spec/unit/digestable_spec.rb +13 -13
- data/spec/unit/fetcher_spec.rb +11 -12
- data/spec/unit/fetchers/git_fetcher_spec.rb +31 -31
- data/spec/unit/fetchers/net_fetcher_spec.rb +172 -173
- data/spec/unit/fetchers/path_fetcher_spec.rb +18 -18
- data/spec/unit/generator_spec.rb +38 -38
- data/spec/unit/git_cache_spec.rb +56 -54
- data/spec/unit/git_repository_spec.rb +2 -2
- data/spec/unit/health_check_spec.rb +40 -40
- data/spec/unit/library_spec.rb +35 -35
- data/spec/unit/manifest_diff_spec.rb +10 -11
- data/spec/unit/manifest_spec.rb +17 -17
- data/spec/unit/metadata_spec.rb +152 -152
- data/spec/unit/ohai_spec.rb +5 -5
- data/spec/unit/omnibus_spec.rb +31 -31
- data/spec/unit/package_spec.rb +20 -20
- data/spec/unit/packager_spec.rb +48 -42
- data/spec/unit/packagers/appx_spec.rb +165 -0
- data/spec/unit/packagers/base_spec.rb +34 -34
- data/spec/unit/packagers/bff_spec.rb +60 -60
- data/spec/unit/packagers/deb_spec.rb +71 -71
- data/spec/unit/packagers/ips_spec.rb +45 -45
- data/spec/unit/packagers/makeself_spec.rb +22 -22
- data/spec/unit/packagers/msi_spec.rb +141 -147
- data/spec/unit/packagers/pkg_spec.rb +59 -60
- data/spec/unit/packagers/rpm_spec.rb +125 -126
- data/spec/unit/packagers/solaris_spec.rb +52 -52
- data/spec/unit/project_spec.rb +137 -135
- data/spec/unit/publisher_spec.rb +70 -70
- data/spec/unit/publishers/artifactory_publisher_spec.rb +85 -85
- data/spec/unit/publishers/s3_publisher_spec.rb +36 -36
- data/spec/unit/s3_cacher_spec.rb +34 -34
- data/spec/unit/s3_helpers_spec.rb +6 -6
- data/spec/unit/semantic_version_spec.rb +2 -2
- data/spec/unit/software_spec.rb +346 -384
- data/spec/unit/sugarable_spec.rb +10 -10
- data/spec/unit/util_spec.rb +60 -60
- metadata +54 -6
- data/.rubocop.yml +0 -48
data/spec/unit/metadata_spec.rb
CHANGED
@@ -1,46 +1,46 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
module Omnibus
|
4
4
|
describe Metadata do
|
5
5
|
let(:instance) do
|
6
|
-
double(described_class, path:
|
6
|
+
double(described_class, path: "/path/to/package.deb.metadata.json")
|
7
7
|
end
|
8
8
|
|
9
|
-
let(:package_path) {
|
10
|
-
let(:license_path) {
|
9
|
+
let(:package_path) { "/path/to/package.deb" }
|
10
|
+
let(:license_path) { "/opt/project/LICENSE" }
|
11
11
|
|
12
12
|
let(:package) do
|
13
13
|
double(Package,
|
14
|
-
name:
|
14
|
+
name: "package",
|
15
15
|
path: package_path,
|
16
|
-
md5:
|
17
|
-
sha1:
|
18
|
-
sha256:
|
19
|
-
sha512:
|
16
|
+
md5: "abc123",
|
17
|
+
sha1: "abc123",
|
18
|
+
sha256: "abcd1234",
|
19
|
+
sha512: "abcdef123456"
|
20
20
|
)
|
21
21
|
end
|
22
22
|
|
23
23
|
let(:project) do
|
24
24
|
double(Project,
|
25
|
-
name:
|
26
|
-
friendly_name:
|
27
|
-
homepage:
|
28
|
-
build_version:
|
29
|
-
build_iteration:
|
30
|
-
license:
|
25
|
+
name: "some-project",
|
26
|
+
friendly_name: "Some Project",
|
27
|
+
homepage: "https://some.project.io",
|
28
|
+
build_version: "1.2.3",
|
29
|
+
build_iteration: "1",
|
30
|
+
license: "Apache-2.0",
|
31
31
|
built_manifest: double(Manifest,
|
32
32
|
to_hash: {
|
33
33
|
manifest_format: 2,
|
34
|
-
build_version:
|
35
|
-
build_git_revision:
|
36
|
-
license:
|
34
|
+
build_version: "1.2.3",
|
35
|
+
build_git_revision: "SHA",
|
36
|
+
license: "Apache-2.0",
|
37
37
|
}
|
38
38
|
),
|
39
|
-
license_file_path: license_path
|
39
|
+
license_file_path: license_path
|
40
40
|
)
|
41
41
|
end
|
42
42
|
|
43
|
-
let(:data) { { foo:
|
43
|
+
let(:data) { { foo: "bar" } }
|
44
44
|
let(:license_file_content) do
|
45
45
|
<<-EOH
|
46
46
|
some_project 1.2.3 license: "Apache-2.0"
|
@@ -61,9 +61,9 @@ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
61
61
|
|
62
62
|
subject { described_class.new(package, data) }
|
63
63
|
|
64
|
-
describe
|
64
|
+
describe ".generate" do
|
65
65
|
let(:metadata_json_content) { StringIO.new }
|
66
|
-
let(:package_path) {
|
66
|
+
let(:package_path) { "/path/to/package.deb" }
|
67
67
|
|
68
68
|
before do
|
69
69
|
allow(File).to receive(:exist?).with(package_path).and_return(true)
|
@@ -71,137 +71,137 @@ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
71
71
|
allow(File).to receive(:exist?).with(license_path).and_return(true)
|
72
72
|
allow(File).to receive(:read).with(license_path).and_return(license_file_content)
|
73
73
|
# mock out `Metadata#save`
|
74
|
-
allow(File).to receive(:open).with("#{package_path}.metadata.json",
|
74
|
+
allow(File).to receive(:open).with("#{package_path}.metadata.json", "w+").and_yield(metadata_json_content)
|
75
75
|
end
|
76
76
|
|
77
|
-
it
|
77
|
+
it "creates a *.metadata.json file with the correct content" do
|
78
78
|
|
79
79
|
described_class.generate(package_path, project)
|
80
80
|
|
81
81
|
expect(metadata_json_content.string).to include_json(
|
82
|
-
basename:
|
83
|
-
md5:
|
84
|
-
sha1:
|
85
|
-
sha256:
|
86
|
-
sha512:
|
87
|
-
platform:
|
88
|
-
platform_version:
|
89
|
-
arch:
|
90
|
-
name:
|
91
|
-
friendly_name:
|
92
|
-
homepage:
|
93
|
-
version:
|
94
|
-
iteration:
|
82
|
+
basename: "package",
|
83
|
+
md5: "abc123",
|
84
|
+
sha1: "abc123",
|
85
|
+
sha256: "abcd1234",
|
86
|
+
sha512: "abcdef123456",
|
87
|
+
platform: "ubuntu",
|
88
|
+
platform_version: "12.04",
|
89
|
+
arch: "x86_64",
|
90
|
+
name: "some-project",
|
91
|
+
friendly_name: "Some Project",
|
92
|
+
homepage: "https://some.project.io",
|
93
|
+
version: "1.2.3",
|
94
|
+
iteration: "1",
|
95
95
|
version_manifest: {
|
96
96
|
manifest_format: 2,
|
97
|
-
build_version:
|
98
|
-
build_git_revision:
|
99
|
-
license:
|
97
|
+
build_version: "1.2.3",
|
98
|
+
build_git_revision: "SHA",
|
99
|
+
license: "Apache-2.0",
|
100
100
|
},
|
101
|
-
license_content: license_file_content
|
101
|
+
license_content: license_file_content
|
102
102
|
)
|
103
103
|
end
|
104
104
|
|
105
|
-
context
|
105
|
+
context "the package file does not exist" do
|
106
106
|
before do
|
107
107
|
allow(File).to receive(:exist?).with(package_path).and_return(false)
|
108
108
|
end
|
109
109
|
|
110
|
-
it
|
110
|
+
it "raises an exception" do
|
111
111
|
expect { described_class.generate(package_path, project) }.to raise_error(Omnibus::NoPackageFile)
|
112
112
|
end
|
113
113
|
end
|
114
114
|
|
115
|
-
context
|
115
|
+
context "the license file does not exist" do
|
116
116
|
before do
|
117
117
|
allow(File).to receive(:exist?).with(license_path).and_return(false)
|
118
118
|
end
|
119
119
|
|
120
|
-
it
|
120
|
+
it "does not include the license content" do
|
121
121
|
described_class.generate(package_path, project)
|
122
122
|
expect(metadata_json_content.string).to include_json(
|
123
|
-
license_content:
|
123
|
+
license_content: ""
|
124
124
|
)
|
125
125
|
end
|
126
126
|
end
|
127
127
|
end
|
128
128
|
|
129
|
-
describe
|
130
|
-
let(:architecture) {
|
129
|
+
describe ".arch" do
|
130
|
+
let(:architecture) { "x86_64" }
|
131
131
|
|
132
132
|
before do
|
133
|
-
stub_ohai(platform:
|
134
|
-
data[
|
133
|
+
stub_ohai(platform: "ubuntu", version: "12.04") do |data|
|
134
|
+
data["kernel"]["machine"] = architecture
|
135
135
|
end
|
136
136
|
end
|
137
137
|
|
138
|
-
it
|
139
|
-
expect(described_class.arch).to eq(
|
138
|
+
it "returns the architecture" do
|
139
|
+
expect(described_class.arch).to eq("x86_64")
|
140
140
|
end
|
141
141
|
|
142
|
-
context
|
142
|
+
context "on solaris" do
|
143
143
|
before do
|
144
|
-
stub_ohai(platform:
|
145
|
-
data[
|
146
|
-
data[
|
144
|
+
stub_ohai(platform: "solaris2", version: "5.11") do |data|
|
145
|
+
data["platform"] = "solaris2"
|
146
|
+
data["kernel"]["machine"] = architecture
|
147
147
|
end
|
148
148
|
end
|
149
149
|
|
150
|
-
context
|
151
|
-
let(:architecture) {
|
150
|
+
context "architecture is Intel-based" do
|
151
|
+
let(:architecture) { "i86pc" }
|
152
152
|
|
153
|
-
it
|
154
|
-
expect(described_class.arch).to eq(
|
153
|
+
it "returns i386" do
|
154
|
+
expect(described_class.arch).to eq("i386")
|
155
155
|
end
|
156
156
|
end
|
157
157
|
|
158
|
-
context
|
159
|
-
let(:architecture) {
|
158
|
+
context "architecture is SPARC-based" do
|
159
|
+
let(:architecture) { "sun4v" }
|
160
160
|
|
161
|
-
it
|
162
|
-
expect(described_class.arch).to eq(
|
161
|
+
it "returns sparc" do
|
162
|
+
expect(described_class.arch).to eq("sparc")
|
163
163
|
end
|
164
164
|
end
|
165
165
|
end
|
166
166
|
|
167
|
-
context
|
167
|
+
context "on windows" do
|
168
168
|
before do
|
169
|
-
stub_ohai(platform:
|
170
|
-
data[
|
169
|
+
stub_ohai(platform: "windows", version: "2012R2") do |data|
|
170
|
+
data["kernel"]["machine"] = architecture
|
171
171
|
end
|
172
172
|
end
|
173
173
|
|
174
|
-
it
|
174
|
+
it "returns a 32-bit value based on Config.windows_arch being set to x86" do
|
175
175
|
expect(Config).to receive(:windows_arch).and_return(:x86)
|
176
|
-
expect(described_class.arch).to eq(
|
176
|
+
expect(described_class.arch).to eq("i386")
|
177
177
|
end
|
178
178
|
end
|
179
179
|
end
|
180
180
|
|
181
|
-
describe
|
182
|
-
it
|
183
|
-
stub_ohai(platform:
|
184
|
-
expect(described_class.platform_shortname).to eq(
|
181
|
+
describe ".platform_shortname" do
|
182
|
+
it "returns el on rhel" do
|
183
|
+
stub_ohai(platform: "redhat", version: "6.4")
|
184
|
+
expect(described_class.platform_shortname).to eq("el")
|
185
185
|
end
|
186
186
|
|
187
|
-
it
|
188
|
-
stub_ohai(platform:
|
189
|
-
expect(described_class.platform_shortname).to eq(
|
187
|
+
it "returns sles on suse" do
|
188
|
+
stub_ohai(platform: "suse", version: "12.0")
|
189
|
+
expect(described_class.platform_shortname).to eq("sles")
|
190
190
|
end
|
191
191
|
|
192
|
-
it
|
193
|
-
stub_ohai(platform:
|
194
|
-
expect(described_class.platform_shortname).to eq(
|
192
|
+
it "returns .platform on all other systems" do
|
193
|
+
stub_ohai(platform: "ubuntu", version: "12.04")
|
194
|
+
expect(described_class.platform_shortname).to eq("ubuntu")
|
195
195
|
end
|
196
196
|
end
|
197
197
|
|
198
|
-
describe
|
199
|
-
shared_examples
|
198
|
+
describe ".platform_version" do
|
199
|
+
shared_examples "a version manipulator" do |platform_shortname, version, expected|
|
200
200
|
context "on #{platform_shortname}-#{version}" do
|
201
|
-
it
|
202
|
-
stub_ohai(platform:
|
203
|
-
data[
|
204
|
-
data[
|
201
|
+
it "returns the correct value" do
|
202
|
+
stub_ohai(platform: "ubuntu", version: "12.04") do |data|
|
203
|
+
data["platform"] = platform_shortname
|
204
|
+
data["platform_version"] = version
|
205
205
|
end
|
206
206
|
|
207
207
|
expect(described_class.platform_version).to eq(expected)
|
@@ -209,112 +209,112 @@ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
209
209
|
end
|
210
210
|
end
|
211
211
|
|
212
|
-
it_behaves_like
|
213
|
-
it_behaves_like
|
214
|
-
it_behaves_like
|
215
|
-
it_behaves_like
|
216
|
-
it_behaves_like
|
217
|
-
it_behaves_like
|
218
|
-
it_behaves_like
|
219
|
-
it_behaves_like
|
220
|
-
it_behaves_like
|
221
|
-
it_behaves_like
|
222
|
-
it_behaves_like
|
223
|
-
it_behaves_like
|
224
|
-
it_behaves_like
|
225
|
-
it_behaves_like
|
226
|
-
it_behaves_like
|
227
|
-
it_behaves_like
|
228
|
-
it_behaves_like
|
229
|
-
it_behaves_like
|
230
|
-
it_behaves_like
|
231
|
-
it_behaves_like
|
232
|
-
it_behaves_like
|
233
|
-
it_behaves_like
|
234
|
-
it_behaves_like
|
235
|
-
it_behaves_like
|
236
|
-
it_behaves_like
|
237
|
-
it_behaves_like
|
238
|
-
it_behaves_like
|
239
|
-
it_behaves_like
|
240
|
-
it_behaves_like
|
241
|
-
it_behaves_like
|
242
|
-
it_behaves_like
|
243
|
-
it_behaves_like
|
244
|
-
it_behaves_like
|
245
|
-
it_behaves_like
|
246
|
-
it_behaves_like
|
247
|
-
|
248
|
-
context
|
212
|
+
it_behaves_like "a version manipulator", "aix", "7.1", "7.1"
|
213
|
+
it_behaves_like "a version manipulator", "arch", "rolling", "rolling"
|
214
|
+
it_behaves_like "a version manipulator", "centos", "5.9.6", "5"
|
215
|
+
it_behaves_like "a version manipulator", "debian", "7.1", "7"
|
216
|
+
it_behaves_like "a version manipulator", "debian", "6.9", "6"
|
217
|
+
it_behaves_like "a version manipulator", "el", "6.5", "6"
|
218
|
+
it_behaves_like "a version manipulator", "fedora", "11.5", "11"
|
219
|
+
it_behaves_like "a version manipulator", "freebsd", "10.0", "10"
|
220
|
+
it_behaves_like "a version manipulator", "gentoo", "2004.3", "2004.3"
|
221
|
+
it_behaves_like "a version manipulator", "ios_xr", "6.0.0.14I", "6"
|
222
|
+
it_behaves_like "a version manipulator", "mac_os_x", "10.9.1", "10.9"
|
223
|
+
it_behaves_like "a version manipulator", "nexus", "5.0", "5"
|
224
|
+
it_behaves_like "a version manipulator", "omnios", "r151010", "r151010"
|
225
|
+
it_behaves_like "a version manipulator", "openbsd", "5.4.4", "5.4"
|
226
|
+
it_behaves_like "a version manipulator", "opensuse", "5.9", "5.9"
|
227
|
+
it_behaves_like "a version manipulator", "pidora", "11.5", "11"
|
228
|
+
it_behaves_like "a version manipulator", "raspbian", "7.1", "7"
|
229
|
+
it_behaves_like "a version manipulator", "rhel", "6.5", "6"
|
230
|
+
it_behaves_like "a version manipulator", "slackware", "12.0.1", "12.0"
|
231
|
+
it_behaves_like "a version manipulator", "sles", "11.2", "11"
|
232
|
+
it_behaves_like "a version manipulator", "suse", "12.0", "12"
|
233
|
+
it_behaves_like "a version manipulator", "smartos", "20120809T221258Z", "20120809T221258Z"
|
234
|
+
it_behaves_like "a version manipulator", "solaris2", "5.9", "5.9"
|
235
|
+
it_behaves_like "a version manipulator", "ubuntu", "10.04", "10.04"
|
236
|
+
it_behaves_like "a version manipulator", "ubuntu", "10.04.04", "10.04"
|
237
|
+
it_behaves_like "a version manipulator", "windows", "5.0.2195", "2000"
|
238
|
+
it_behaves_like "a version manipulator", "windows", "5.1.2600", "xp"
|
239
|
+
it_behaves_like "a version manipulator", "windows", "5.2.3790", "2003r2"
|
240
|
+
it_behaves_like "a version manipulator", "windows", "6.0.6001", "2008"
|
241
|
+
it_behaves_like "a version manipulator", "windows", "6.1.7600", "7"
|
242
|
+
it_behaves_like "a version manipulator", "windows", "6.1.7601", "2008r2"
|
243
|
+
it_behaves_like "a version manipulator", "windows", "6.2.9200", "2012"
|
244
|
+
it_behaves_like "a version manipulator", "windows", "6.3.9200", "2012r2"
|
245
|
+
it_behaves_like "a version manipulator", "windows", "6.3.9600", "2012r2"
|
246
|
+
it_behaves_like "a version manipulator", "windows", "10.0.10240", "10"
|
247
|
+
|
248
|
+
context "given an unknown platform" do
|
249
249
|
before do
|
250
|
-
stub_ohai(platform:
|
251
|
-
data[
|
252
|
-
data[
|
250
|
+
stub_ohai(platform: "ubuntu", version: "12.04") do |data|
|
251
|
+
data["platform"] = "bacon"
|
252
|
+
data["platform_version"] = "1.crispy"
|
253
253
|
end
|
254
254
|
end
|
255
255
|
|
256
|
-
it
|
256
|
+
it "raises an exception" do
|
257
257
|
expect { described_class.platform_version }
|
258
258
|
.to raise_error(UnknownPlatform)
|
259
259
|
end
|
260
260
|
end
|
261
261
|
|
262
|
-
context
|
262
|
+
context "given an unknown windows platform version" do
|
263
263
|
before do
|
264
|
-
stub_ohai(platform:
|
265
|
-
data[
|
266
|
-
data[
|
264
|
+
stub_ohai(platform: "ubuntu", version: "12.04") do |data|
|
265
|
+
data["platform"] = "windows"
|
266
|
+
data["platform_version"] = "1.2.3"
|
267
267
|
end
|
268
268
|
end
|
269
269
|
|
270
|
-
it
|
270
|
+
it "raises an exception" do
|
271
271
|
expect { described_class.platform_version }
|
272
272
|
.to raise_error(UnknownPlatformVersion)
|
273
273
|
end
|
274
274
|
end
|
275
275
|
end
|
276
276
|
|
277
|
-
describe
|
278
|
-
it
|
277
|
+
describe ".for_package" do
|
278
|
+
it "raises an exception when the file does not exist" do
|
279
279
|
allow(File).to receive(:read).and_raise(Errno::ENOENT)
|
280
280
|
expect { described_class.for_package(package) }
|
281
281
|
.to raise_error(NoPackageMetadataFile)
|
282
282
|
end
|
283
283
|
|
284
|
-
it
|
284
|
+
it "returns a metadata object" do
|
285
285
|
allow(File).to receive(:read).and_return('{ "platform": "ubuntu" }')
|
286
286
|
expect(described_class.for_package(package)).to be_a(described_class)
|
287
287
|
end
|
288
288
|
|
289
|
-
it
|
289
|
+
it "loads the metadata from disk" do
|
290
290
|
allow(File).to receive(:read).and_return('{ "platform": "ubuntu" }')
|
291
291
|
instance = described_class.for_package(package)
|
292
292
|
|
293
|
-
expect(instance[:platform]).to eq(
|
293
|
+
expect(instance[:platform]).to eq("ubuntu")
|
294
294
|
end
|
295
295
|
|
296
|
-
it
|
296
|
+
it "ensures platform version is properly truncated" do
|
297
297
|
allow(File).to receive(:read).and_return('{ "platform": "el", "platform_version": "5.10" }')
|
298
298
|
instance = described_class.for_package(package)
|
299
299
|
|
300
|
-
expect(instance[:platform_version]).to eq(
|
300
|
+
expect(instance[:platform_version]).to eq("5")
|
301
301
|
end
|
302
302
|
|
303
|
-
it
|
303
|
+
it "correctly truncates sles platform versions" do
|
304
304
|
allow(File).to receive(:read).and_return('{ "platform": "sles", "platform_version": "11.2" }')
|
305
305
|
instance = described_class.for_package(package)
|
306
306
|
|
307
|
-
expect(instance[:platform_version]).to eq(
|
307
|
+
expect(instance[:platform_version]).to eq("11")
|
308
308
|
end
|
309
309
|
|
310
|
-
it
|
311
|
-
allow(File).to receive(:read).and_return(
|
310
|
+
it "ensures an iteration exists" do
|
311
|
+
allow(File).to receive(:read).and_return("{}")
|
312
312
|
instance = described_class.for_package(package)
|
313
313
|
|
314
314
|
expect(instance[:iteration]).to eq(1)
|
315
315
|
end
|
316
316
|
|
317
|
-
it
|
317
|
+
it "does not change existing iterations" do
|
318
318
|
allow(File).to receive(:read).and_return('{ "iteration": 4 }')
|
319
319
|
instance = described_class.for_package(package)
|
320
320
|
|
@@ -322,21 +322,21 @@ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
322
322
|
end
|
323
323
|
end
|
324
324
|
|
325
|
-
describe
|
326
|
-
it
|
325
|
+
describe ".path_for" do
|
326
|
+
it "returns the postfixed .metadata.json" do
|
327
327
|
expect(described_class.path_for(package))
|
328
|
-
.to eq(
|
328
|
+
.to eq("/path/to/package.deb.metadata.json")
|
329
329
|
end
|
330
330
|
end
|
331
331
|
|
332
332
|
describe '#name' do
|
333
|
-
it
|
334
|
-
expect(subject.name).to eq(
|
333
|
+
it "returns the basename of the package" do
|
334
|
+
expect(subject.name).to eq("package.deb.metadata.json")
|
335
335
|
end
|
336
336
|
end
|
337
337
|
|
338
338
|
describe '#path' do
|
339
|
-
it
|
339
|
+
it "delegates to .path_for" do
|
340
340
|
expect(described_class).to receive(:path_for).once
|
341
341
|
subject.path
|
342
342
|
end
|
@@ -347,15 +347,15 @@ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
347
347
|
|
348
348
|
before { allow(File).to receive(:open).and_yield(file) }
|
349
349
|
|
350
|
-
it
|
350
|
+
it "saves the file to disk" do
|
351
351
|
expect(file).to receive(:write).once
|
352
352
|
subject.save
|
353
353
|
end
|
354
354
|
end
|
355
355
|
|
356
356
|
describe '#to_json' do
|
357
|
-
it
|
358
|
-
expect(subject.to_json.strip).to eq <<-EOH.gsub(/^ {10}/,
|
357
|
+
it "generates pretty JSON" do
|
358
|
+
expect(subject.to_json.strip).to eq <<-EOH.gsub(/^ {10}/, "").strip
|
359
359
|
{
|
360
360
|
"foo": "bar"
|
361
361
|
}
|
data/spec/unit/ohai_spec.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
module Omnibus
|
4
4
|
describe Ohai do
|
5
|
-
context
|
6
|
-
it
|
7
|
-
expect { Ohai[
|
8
|
-
expect { Ohai[
|
5
|
+
context "using hash notation" do
|
6
|
+
it "allows fetching values by hash notation" do
|
7
|
+
expect { Ohai["kernel"] }.to_not raise_error
|
8
|
+
expect { Ohai["kernel"]["machine"] }.to_not raise_error
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|