puppet 2.7.13 → 2.7.14

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puppet might be problematic. Click here for more details.

Files changed (215) hide show
  1. data/CHANGELOG +144 -1
  2. data/conf/osx/preflight +1 -1
  3. data/conf/redhat/puppet.spec +9 -5
  4. data/conf/suse/puppet.spec +4 -1
  5. data/conf/windows/eventlog/Rakefile +32 -0
  6. data/conf/windows/eventlog/puppetres.dll +0 -0
  7. data/conf/windows/eventlog/puppetres.mc +18 -0
  8. data/ext/rack/files/apache2.conf +3 -0
  9. data/install.rb +23 -1
  10. data/lib/puppet.rb +1 -1
  11. data/lib/puppet/agent.rb +1 -14
  12. data/lib/puppet/application/kick.rb +1 -1
  13. data/lib/puppet/application/module.rb +11 -0
  14. data/lib/puppet/daemon.rb +74 -3
  15. data/lib/puppet/defaults.rb +1 -1
  16. data/lib/puppet/face/certificate.rb +1 -1
  17. data/lib/puppet/face/help/man.erb +1 -1
  18. data/lib/puppet/face/module.rb +17 -0
  19. data/lib/puppet/face/module/build.rb +10 -4
  20. data/lib/puppet/face/module/changes.rb +5 -5
  21. data/lib/puppet/face/module/generate.rb +6 -4
  22. data/lib/puppet/face/module/install.rb +122 -32
  23. data/lib/puppet/face/module/list.rb +234 -33
  24. data/lib/puppet/face/module/search.rb +56 -23
  25. data/lib/puppet/face/module/uninstall.rb +33 -38
  26. data/lib/puppet/face/module/upgrade.rb +84 -0
  27. data/lib/puppet/feature/eventlog.rb +6 -0
  28. data/lib/puppet/forge.rb +67 -122
  29. data/lib/puppet/forge/cache.rb +1 -1
  30. data/lib/puppet/forge/repository.rb +6 -25
  31. data/lib/puppet/indirector/facts/network_device.rb +1 -1
  32. data/lib/puppet/interface/action.rb +1 -1
  33. data/lib/puppet/module.rb +79 -28
  34. data/lib/puppet/module_tool.rb +72 -34
  35. data/lib/puppet/module_tool/applications.rb +12 -14
  36. data/lib/puppet/module_tool/applications/application.rb +21 -19
  37. data/lib/puppet/module_tool/applications/builder.rb +4 -4
  38. data/lib/puppet/module_tool/applications/checksummer.rb +12 -3
  39. data/lib/puppet/module_tool/applications/generator.rb +1 -1
  40. data/lib/puppet/module_tool/applications/installer.rb +163 -34
  41. data/lib/puppet/module_tool/applications/searcher.rb +2 -3
  42. data/lib/puppet/module_tool/applications/uninstaller.rb +84 -36
  43. data/lib/puppet/module_tool/applications/unpacker.rb +4 -26
  44. data/lib/puppet/module_tool/applications/upgrader.rb +109 -0
  45. data/lib/puppet/module_tool/checksums.rb +2 -2
  46. data/lib/puppet/module_tool/contents_description.rb +1 -1
  47. data/lib/puppet/module_tool/dependency.rb +2 -2
  48. data/lib/puppet/module_tool/errors.rb +9 -0
  49. data/lib/puppet/module_tool/errors/base.rb +15 -0
  50. data/lib/puppet/module_tool/errors/installer.rb +90 -0
  51. data/lib/puppet/module_tool/errors/shared.rb +115 -0
  52. data/lib/puppet/module_tool/errors/uninstaller.rb +45 -0
  53. data/lib/puppet/module_tool/errors/upgrader.rb +72 -0
  54. data/lib/puppet/module_tool/metadata.rb +2 -2
  55. data/lib/puppet/module_tool/modulefile.rb +7 -7
  56. data/lib/puppet/module_tool/shared_behaviors.rb +161 -0
  57. data/lib/puppet/module_tool/skeleton.rb +1 -1
  58. data/lib/puppet/node/environment.rb +4 -2
  59. data/lib/puppet/parser/ast/leaf.rb +1 -1
  60. data/lib/puppet/parser/functions/create_resources.rb +3 -2
  61. data/lib/puppet/parser/scope.rb +44 -9
  62. data/lib/puppet/provider/augeas/augeas.rb +2 -2
  63. data/lib/puppet/provider/exec.rb +8 -3
  64. data/lib/puppet/provider/exec/shell.rb +1 -2
  65. data/lib/puppet/provider/nameservice/directoryservice.rb +10 -4
  66. data/lib/puppet/provider/package/gem.rb +1 -1
  67. data/lib/puppet/provider/package/pkg.rb +10 -21
  68. data/lib/puppet/provider/selmodule/semodule.rb +1 -2
  69. data/lib/puppet/provider/service/upstart.rb +33 -17
  70. data/lib/puppet/provider/ssh_authorized_key/parsed.rb +1 -1
  71. data/lib/puppet/rails/inventory_node.rb +7 -7
  72. data/lib/puppet/reports/http.rb +4 -1
  73. data/lib/puppet/reports/tagmail.rb +8 -1
  74. data/lib/puppet/resource/type.rb +1 -1
  75. data/lib/puppet/test/test_helper.rb +138 -0
  76. data/lib/puppet/type.rb +9 -1
  77. data/lib/puppet/type/file.rb +18 -10
  78. data/lib/puppet/type/package.rb +13 -9
  79. data/lib/puppet/type/resources.rb +1 -1
  80. data/lib/puppet/type/ssh_authorized_key.rb +3 -4
  81. data/lib/puppet/type/sshkey.rb +4 -4
  82. data/lib/puppet/type/user.rb +1 -0
  83. data/lib/puppet/type/vlan.rb +1 -1
  84. data/lib/puppet/util.rb +31 -14
  85. data/lib/puppet/util/autoload.rb +1 -1
  86. data/lib/puppet/util/command_line.rb +2 -6
  87. data/lib/puppet/util/instrumentation/indirection_probe.rb +1 -1
  88. data/lib/puppet/util/instrumentation/instrumentable.rb +1 -1
  89. data/lib/puppet/util/instrumentation/listeners/log.rb +1 -1
  90. data/lib/puppet/util/instrumentation/listeners/performance.rb +1 -1
  91. data/lib/puppet/util/log.rb +3 -1
  92. data/lib/puppet/util/log/destinations.rb +38 -0
  93. data/lib/puppet/util/monkey_patches.rb +45 -0
  94. data/lib/puppet/util/network_device/base.rb +1 -1
  95. data/lib/puppet/util/network_device/cisco.rb +1 -1
  96. data/lib/puppet/util/network_device/cisco/facts.rb +1 -1
  97. data/lib/puppet/util/network_device/cisco/interface.rb +1 -1
  98. data/lib/puppet/util/network_device/config.rb +1 -1
  99. data/lib/puppet/util/network_device/ipcalc.rb +1 -1
  100. data/lib/puppet/util/network_device/transport.rb +1 -1
  101. data/lib/puppet/util/network_device/transport/base.rb +1 -1
  102. data/lib/puppet/util/network_device/transport/ssh.rb +1 -1
  103. data/lib/puppet/util/settings.rb +2 -11
  104. data/lib/puppet/util/settings/file_setting.rb +3 -5
  105. data/lib/puppet/util/terminal.rb +16 -0
  106. data/lib/puppet/util/zaml.rb +3 -1
  107. data/lib/semver.rb +15 -7
  108. data/spec/fixtures/releases/jamtur01-apache/metadata.json +1 -1
  109. data/spec/fixtures/unit/parser/lexer/arithmetic_expression.pp +1 -1
  110. data/spec/fixtures/unit/provider/package/pkg/dummy +1 -0
  111. data/spec/fixtures/unit/provider/package/pkg/incomplete +1 -0
  112. data/spec/fixtures/unit/provider/package/pkg/publisher +2 -0
  113. data/spec/fixtures/unit/provider/package/pkg/simple +4 -0
  114. data/spec/fixtures/unit/reports/tagmail/tagmail_email.conf +2 -0
  115. data/spec/fixtures/yaml/report0.25.x.yaml +1 -1
  116. data/spec/fixtures/yaml/report2.6.x.yaml +1 -1
  117. data/spec/integration/faces/documentation_spec.rb +1 -1
  118. data/spec/integration/network/rest_authconfig_spec.rb +1 -1
  119. data/spec/lib/puppet_spec/compiler.rb +6 -0
  120. data/spec/lib/puppet_spec/database.rb +30 -0
  121. data/spec/lib/puppet_spec/files.rb +4 -2
  122. data/spec/shared_behaviours/path_parameters.rb +2 -29
  123. data/spec/shared_contexts/platform.rb +43 -0
  124. data/spec/spec_helper.rb +36 -65
  125. data/spec/unit/agent_spec.rb +0 -32
  126. data/spec/unit/application/kick_spec.rb +2 -2
  127. data/spec/unit/daemon_spec.rb +1 -17
  128. data/spec/unit/face/module/install_spec.rb +158 -0
  129. data/spec/unit/face/module/list_spec.rb +182 -0
  130. data/spec/unit/face/module/search_spec.rb +163 -0
  131. data/spec/unit/face/module/uninstall_spec.rb +77 -0
  132. data/spec/unit/face/module/upgrade_spec.rb +26 -0
  133. data/spec/unit/forge/repository_spec.rb +0 -30
  134. data/spec/unit/forge_spec.rb +28 -86
  135. data/spec/unit/indirector/catalog/active_record_spec.rb +45 -65
  136. data/spec/unit/indirector/facts/inventory_active_record_spec.rb +5 -18
  137. data/spec/unit/indirector/resource/active_record_spec.rb +2 -11
  138. data/spec/unit/indirector/resource/ral_spec.rb +7 -2
  139. data/spec/unit/module_spec.rb +240 -107
  140. data/spec/unit/module_tool/application_spec.rb +3 -5
  141. data/spec/unit/module_tool/applications/application_spec.rb +19 -0
  142. data/spec/unit/module_tool/applications/installer_spec.rb +205 -0
  143. data/spec/unit/module_tool/applications/uninstaller_spec.rb +206 -0
  144. data/spec/unit/module_tool/applications/upgrader_spec.rb +37 -0
  145. data/spec/unit/module_tool/metadata_spec.rb +2 -2
  146. data/spec/unit/module_tool_spec.rb +109 -1
  147. data/spec/unit/node/environment_spec.rb +16 -1
  148. data/spec/unit/parser/ast/leaf_spec.rb +16 -1
  149. data/spec/unit/parser/collector_spec.rb +2 -12
  150. data/spec/unit/parser/functions/create_resources_spec.rb +135 -86
  151. data/spec/unit/parser/functions/generate_spec.rb +2 -10
  152. data/spec/unit/parser/scope_spec.rb +345 -16
  153. data/spec/unit/provider/augeas/augeas_spec.rb +19 -0
  154. data/spec/unit/provider/exec/shell_spec.rb +17 -14
  155. data/spec/unit/provider/exec/windows_spec.rb +1 -7
  156. data/spec/unit/provider/exec_spec.rb +35 -0
  157. data/spec/unit/provider/nameservice/directoryservice_spec.rb +10 -0
  158. data/spec/unit/provider/package/dpkg_spec.rb +2 -1
  159. data/spec/unit/provider/package/gem_spec.rb +15 -0
  160. data/spec/unit/provider/package/openbsd_spec.rb +5 -4
  161. data/spec/unit/provider/package/pacman_spec.rb +3 -2
  162. data/spec/unit/provider/package/pkg_spec.rb +56 -33
  163. data/spec/unit/provider/selmodule_spec.rb +11 -4
  164. data/spec/unit/provider/service/redhat_spec.rb +1 -3
  165. data/spec/unit/provider/service/smf_spec.rb +1 -3
  166. data/spec/unit/provider/service/upstart_spec.rb +38 -0
  167. data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +28 -0
  168. data/spec/unit/rails/host_spec.rb +6 -12
  169. data/spec/unit/rails/param_value_spec.rb +3 -8
  170. data/spec/unit/rails/resource_spec.rb +2 -8
  171. data/spec/unit/reports/http_spec.rb +47 -31
  172. data/spec/unit/reports/tagmail_spec.rb +77 -0
  173. data/spec/unit/resource/type_spec.rb +2 -2
  174. data/spec/unit/resource_spec.rb +18 -20
  175. data/spec/unit/semver_spec.rb +31 -13
  176. data/spec/unit/type/exec_spec.rb +8 -15
  177. data/spec/unit/type/group_spec.rb +0 -9
  178. data/spec/unit/type/package_spec.rb +10 -0
  179. data/spec/unit/type/resources_spec.rb +4 -5
  180. data/spec/unit/type/ssh_authorized_key_spec.rb +4 -15
  181. data/spec/unit/type/sshkey_spec.rb +9 -11
  182. data/spec/unit/type/user_spec.rb +123 -127
  183. data/spec/unit/type_spec.rb +20 -0
  184. data/spec/unit/util/command_line_spec.rb +2 -2
  185. data/spec/unit/util/instrumentation/data_spec.rb +1 -1
  186. data/spec/unit/util/instrumentation/indirection_probe_spec.rb +1 -1
  187. data/spec/unit/util/instrumentation/instrumentable_spec.rb +1 -1
  188. data/spec/unit/util/instrumentation/listener_spec.rb +1 -1
  189. data/spec/unit/util/instrumentation/listeners/log_spec.rb +1 -1
  190. data/spec/unit/util/instrumentation/listeners/performance_spec.rb +1 -1
  191. data/spec/unit/util/instrumentation_spec.rb +1 -1
  192. data/spec/unit/util/log/destinations_spec.rb +4 -8
  193. data/spec/unit/util/log_spec.rb +47 -0
  194. data/spec/unit/util/reference_spec.rb +1 -1
  195. data/spec/unit/util/settings/file_setting_spec.rb +9 -0
  196. data/spec/unit/util/settings_spec.rb +0 -53
  197. data/spec/unit/util/terminal_spec.rb +42 -0
  198. data/spec/unit/util/zaml_spec.rb +7 -0
  199. data/spec/unit/util_spec.rb +63 -20
  200. data/tasks/rake/manpages.rake +1 -1
  201. data/test/data/snippets/arithmetic_expression.pp +1 -1
  202. data/test/other/puppet.rb +0 -1
  203. data/test/util/log.rb +6 -6
  204. metadata +41 -16
  205. data/lib/puppet/external/event-loop.rb +0 -1
  206. data/lib/puppet/external/event-loop/better-definers.rb +0 -367
  207. data/lib/puppet/external/event-loop/event-loop.rb +0 -355
  208. data/lib/puppet/external/event-loop/signal-system.rb +0 -218
  209. data/lib/puppet/face/module/clean.rb +0 -30
  210. data/lib/puppet/module_tool/applications/cleaner.rb +0 -16
  211. data/lib/puppet/module_tool/skeleton/templates/generator/metadata.json +0 -12
  212. data/lib/puppet/module_tool/utils.rb +0 -5
  213. data/lib/puppet/module_tool/utils/interrogation.rb +0 -25
  214. data/spec/integration/module_tool_spec.rb +0 -475
  215. data/spec/unit/module_tool/uninstaller_spec.rb +0 -124
@@ -1,24 +1,18 @@
1
1
  #!/usr/bin/env rspec
2
2
  require 'spec_helper'
3
- begin
4
- require 'sqlite3'
5
- rescue LoadError
6
- end
7
- require 'tempfile'
8
3
  require 'puppet/rails'
9
4
 
10
- describe "Puppet::Node::Facts::InventoryActiveRecord", :if => (Puppet.features.rails? and defined? SQLite3) do
5
+ describe "Puppet::Node::Facts::InventoryActiveRecord", :if => can_use_scratch_database? do
6
+ include PuppetSpec::Files
7
+
11
8
  let(:terminus) { Puppet::Node::Facts::InventoryActiveRecord.new }
12
9
 
13
10
  before :all do
14
11
  require 'puppet/indirector/facts/inventory_active_record'
15
- @dbfile = Tempfile.new("testdb")
16
- @dbfile.close
17
12
  end
18
13
 
19
- after :all do
14
+ after :each do
20
15
  Puppet::Node::Facts.indirection.reset_terminus_class
21
- @dbfile.unlink
22
16
  end
23
17
 
24
18
  before :each do
@@ -26,14 +20,7 @@ describe "Puppet::Node::Facts::InventoryActiveRecord", :if => (Puppet.features.r
26
20
  Puppet::Node.indirection.cache_class = nil
27
21
 
28
22
  Puppet::Node::Facts.indirection.terminus_class = :inventory_active_record
29
- Puppet[:dbadapter] = 'sqlite3'
30
- Puppet[:dblocation] = @dbfile.path
31
- Puppet[:railslog] = "/dev/null"
32
- Puppet::Rails.init
33
- end
34
-
35
- after :each do
36
- Puppet::Rails.teardown
23
+ setup_scratch_database
37
24
  end
38
25
 
39
26
  describe "#save" do
@@ -1,22 +1,13 @@
1
1
  #!/usr/bin/env rspec
2
2
  require 'spec_helper'
3
-
4
- begin
5
- require 'sqlite3'
6
- rescue LoadError
7
- end
8
-
9
3
  require 'puppet/rails'
10
4
  require 'puppet/node/facts'
11
5
 
12
- describe "Puppet::Resource::ActiveRecord", :if => (Puppet.features.rails? and defined? SQLite3) do
6
+ describe "Puppet::Resource::ActiveRecord", :if => can_use_scratch_database? do
13
7
  include PuppetSpec::Files
14
8
 
15
9
  before :each do
16
- dir = Pathname(tmpdir('puppet-var'))
17
- Puppet[:vardir] = dir.to_s
18
- Puppet[:dbadapter] = 'sqlite3'
19
- Puppet[:dblocation] = (dir + 'storeconfigs.sqlite').to_s
10
+ setup_scratch_database
20
11
  Puppet[:storeconfigs] = true
21
12
  end
22
13
 
@@ -20,12 +20,17 @@ describe "Puppet::Resource::Ral" do
20
20
 
21
21
  it "if there is no instance, it should create one", :'fails_on_ruby_1.9.2' => true do
22
22
  wrong_instance = stub "wrong user", :name => "bob"
23
+ root = mock "Root User"
24
+ root_resource = mock "Root Resource"
23
25
 
24
26
  require 'puppet/type/user'
25
27
  Puppet::Type::User.expects(:instances).returns([ wrong_instance, wrong_instance ])
28
+ Puppet::Type::User.expects(:new).with(has_entry(:name => "root")).returns(root)
29
+ root.expects(:to_resource).returns(root_resource)
30
+
26
31
  result = Puppet::Resource::Ral.new.find(@request)
27
- result.should be_is_a(Puppet::Resource)
28
- result.title.should == "root"
32
+
33
+ result.should == root_resource
29
34
  end
30
35
  end
31
36
 
@@ -93,146 +93,227 @@ describe Puppet::Module do
93
93
 
94
94
  describe "when finding unmet dependencies" do
95
95
  before do
96
- @mod = Puppet::Module.new("mymod")
97
- @mod.stubs(:dependencies).returns [
98
- {
99
- "version_requirement" => ">= 2.2.0",
100
- "name" => "baz/foobar"
101
- }
102
- ]
96
+ FileTest.unstub(:exist?)
97
+ @modpath = tmpdir('modpath')
98
+ Puppet.settings[:modulepath] = @modpath
103
99
  end
104
100
 
105
101
  it "should list modules that are missing" do
106
- @mod.unmet_dependencies.should == [{
107
- :name => 'baz/foobar',
108
- :error => <<-HEREDOC.gsub(/^\s{10}/, '')
109
- Missing dependency `foobar`:
110
- `mymod` () requires `baz/foobar` (>= 2.2.0)
111
- HEREDOC
102
+ mod = PuppetSpec::Modules.create(
103
+ 'needy',
104
+ @modpath,
105
+ :metadata => {
106
+ :dependencies => [{
107
+ "version_requirement" => ">= 2.2.0",
108
+ "name" => "baz/foobar"
109
+ }]
110
+ }
111
+ )
112
+ mod.unmet_dependencies.should == [{
113
+ :reason => :missing,
114
+ :name => "baz/foobar",
115
+ :version_constraint => ">= 2.2.0",
116
+ :parent => { :name => 'puppetlabs/needy', :version => 'v9.9.9' },
117
+ :mod_details => { :installed_version => nil }
112
118
  }]
113
119
  end
114
120
 
115
- it "should list modules with unmet version" do
116
- foobar = Puppet::Module.new("foobar")
117
- foobar.version = '2.0.0'
118
- @mod.environment.expects(:module).with("foobar").returns foobar
119
-
120
- @mod.unmet_dependencies.should == [{
121
- :name => 'baz/foobar',
122
- :error => <<-HEREDOC.gsub(/^\s{10}/, '')
123
- Version dependency mismatch `foobar` (2.0.0):
124
- `mymod` () requires `baz/foobar` (>= 2.2.0)
125
- HEREDOC
121
+ it "should list modules that are missing and have invalid names" do
122
+ mod = PuppetSpec::Modules.create(
123
+ 'needy',
124
+ @modpath,
125
+ :metadata => {
126
+ :dependencies => [{
127
+ "version_requirement" => ">= 2.2.0",
128
+ "name" => "baz/foobar=bar"
129
+ }]
130
+ }
131
+ )
132
+ mod.unmet_dependencies.should == [{
133
+ :reason => :missing,
134
+ :name => "baz/foobar=bar",
135
+ :version_constraint => ">= 2.2.0",
136
+ :parent => { :name => 'puppetlabs/needy', :version => 'v9.9.9' },
137
+ :mod_details => { :installed_version => nil }
126
138
  }]
127
139
  end
128
140
 
129
- it "should consider a dependency without a version requirement to be satisfied" do
130
- mod = Puppet::Module.new("mymod")
131
- mod.stubs(:dependencies).returns [{ "name" => "baz/foobar" }]
132
-
133
- foobar = Puppet::Module.new("foobar")
134
- mod.environment.expects(:module).with("foobar").returns foobar
135
-
136
- mod.unmet_dependencies.should be_empty
137
- end
141
+ it "should list modules with unmet version requirement" do
142
+ mod = PuppetSpec::Modules.create(
143
+ 'foobar',
144
+ @modpath,
145
+ :metadata => {
146
+ :dependencies => [{
147
+ "version_requirement" => ">= 2.2.0",
148
+ "name" => "baz/foobar"
149
+ }]
150
+ }
151
+ )
152
+ mod2 = PuppetSpec::Modules.create(
153
+ 'foobaz',
154
+ @modpath,
155
+ :metadata => {
156
+ :dependencies => [{
157
+ "version_requirement" => "1.0.0",
158
+ "name" => "baz/foobar"
159
+ }]
160
+ }
161
+ )
138
162
 
139
- it "should consider a dependency without a version to be unmet" do
140
- foobar = Puppet::Module.new("foobar")
141
- @mod.environment.expects(:module).with("foobar").returns foobar
163
+ PuppetSpec::Modules.create(
164
+ 'foobar',
165
+ @modpath,
166
+ :metadata => { :version => '2.0.0', :author => 'baz' }
167
+ )
142
168
 
143
- @mod.unmet_dependencies.should == [{
144
- :name => 'baz/foobar',
145
- :error => <<-HEREDOC.gsub(/^\s{10}/, '')
146
- Unversioned dependency `foobar`:
147
- `mymod` () requires `baz/foobar` (>= 2.2.0)
148
- HEREDOC
169
+ mod.unmet_dependencies.should == [{
170
+ :reason => :version_mismatch,
171
+ :name => "baz/foobar",
172
+ :version_constraint => ">= 2.2.0",
173
+ :parent => { :version => "v9.9.9", :name => "puppetlabs/foobar" },
174
+ :mod_details => { :installed_version => "2.0.0" }
149
175
  }]
150
- end
151
176
 
152
- it "should consider a dependency without a semantic version to be unmet" do
153
- foobar = Puppet::Module.new("foobar")
154
- foobar.version = '5.1'
155
- @mod.environment.expects(:module).with("foobar").returns foobar
156
-
157
- @mod.unmet_dependencies.should == [{
158
- :name => 'baz/foobar',
159
- :error => <<-HEREDOC.gsub(/^\s{10}/, '')
160
- Non semantic version dependency `foobar` (5.1):
161
- `mymod` () requires `baz/foobar` (>= 2.2.0)
162
- HEREDOC
177
+ mod2.unmet_dependencies.should == [{
178
+ :reason => :version_mismatch,
179
+ :name => "baz/foobar",
180
+ :version_constraint => "v1.0.0",
181
+ :parent => { :version => "v9.9.9", :name => "puppetlabs/foobaz" },
182
+ :mod_details => { :installed_version => "2.0.0" }
163
183
  }]
184
+
164
185
  end
165
186
 
166
- it "should consider a dependency requirement without a semantic version to be unmet" do
167
- foobar = Puppet::Module.new("foobar")
168
- foobar.version = '5.1.0'
187
+ it "should consider a dependency without a version requirement to be satisfied" do
188
+ mod = PuppetSpec::Modules.create(
189
+ 'foobar',
190
+ @modpath,
191
+ :metadata => {
192
+ :dependencies => [{
193
+ "name" => "baz/foobar"
194
+ }]
195
+ }
196
+ )
197
+ PuppetSpec::Modules.create(
198
+ 'foobar',
199
+ @modpath,
200
+ :metadata => {
201
+ :version => '2.0.0',
202
+ :author => 'baz'
203
+ }
204
+ )
205
+
206
+ mod.unmet_dependencies.should be_empty
207
+ end
169
208
 
170
- mod = Puppet::Module.new("mymod")
171
- mod.stubs(:dependencies).returns [{ "name" => "baz/foobar", "version_requirement" => '> 2.0' }]
172
- mod.environment.expects(:module).with("foobar").returns foobar
209
+ it "should consider a dependency without a semantic version to be unmet" do
210
+ mod = PuppetSpec::Modules.create(
211
+ 'foobar',
212
+ @modpath,
213
+ :metadata => {
214
+ :dependencies => [{
215
+ "name" => "baz/foobar"
216
+ }]
217
+ }
218
+ )
219
+ PuppetSpec::Modules.create(
220
+ 'foobar',
221
+ @modpath,
222
+ :metadata => {
223
+ :version => '5.1',
224
+ :author => 'baz'
225
+ }
226
+ )
173
227
 
174
228
  mod.unmet_dependencies.should == [{
175
- :name => 'baz/foobar',
176
- :error => <<-HEREDOC.gsub(/^\s{10}/, '')
177
- Non semantic version dependency `foobar` (5.1.0):
178
- `mymod` () requires `baz/foobar` (> 2.0)
179
- HEREDOC
229
+ :reason => :non_semantic_version,
230
+ :parent => { :version => "v9.9.9", :name => "puppetlabs/foobar" },
231
+ :mod_details => { :installed_version => "5.1" },
232
+ :name => "baz/foobar",
233
+ :version_constraint => ">= 0.0.0"
180
234
  }]
181
235
  end
182
236
 
183
237
  it "should have valid dependencies when no dependencies have been specified" do
184
- mod = Puppet::Module.new("mymod")
238
+ mod = PuppetSpec::Modules.create(
239
+ 'foobar',
240
+ @modpath,
241
+ :metadata => {
242
+ :dependencies => []
243
+ }
244
+ )
185
245
 
186
246
  mod.unmet_dependencies.should == []
187
247
  end
188
248
 
189
249
  it "should only list unmet dependencies" do
190
- mod = Puppet::Module.new("mymod")
191
- mod.stubs(:dependencies).returns [
192
- {
193
- "version_requirement" => ">= 2.2.0",
194
- "name" => "baz/satisfied"
195
- },
196
- {
197
- "version_requirement" => ">= 2.2.0",
198
- "name" => "baz/notsatisfied"
250
+ mod = PuppetSpec::Modules.create(
251
+ 'mymod',
252
+ @modpath,
253
+ :metadata => {
254
+ :dependencies => [
255
+ {
256
+ "version_requirement" => ">= 2.2.0",
257
+ "name" => "baz/satisfied"
258
+ },
259
+ {
260
+ "version_requirement" => ">= 2.2.0",
261
+ "name" => "baz/notsatisfied"
262
+ }
263
+ ]
199
264
  }
200
- ]
201
-
202
- satisfied = Puppet::Module.new("satisfied")
203
- satisfied.version = "3.3.0"
204
-
205
- mod.environment.expects(:module).with("satisfied").returns satisfied
206
- mod.environment.expects(:module).with("notsatisfied").returns nil
265
+ )
266
+ PuppetSpec::Modules.create(
267
+ 'satisfied',
268
+ @modpath,
269
+ :metadata => {
270
+ :version => '3.3.0',
271
+ :author => 'baz'
272
+ }
273
+ )
207
274
 
208
275
  mod.unmet_dependencies.should == [{
209
- :name => 'baz/notsatisfied',
210
- :error => <<-HEREDOC.gsub(/^\s{10}/, '')
211
- Missing dependency `notsatisfied`:
212
- `mymod` () requires `baz/notsatisfied` (>= 2.2.0)
213
- HEREDOC
276
+ :reason => :missing,
277
+ :mod_details => { :installed_version => nil },
278
+ :parent => { :version => "v9.9.9", :name => "puppetlabs/mymod" },
279
+ :name => "baz/notsatisfied",
280
+ :version_constraint => ">= 2.2.0"
214
281
  }]
215
282
  end
216
283
 
217
284
  it "should be empty when all dependencies are met" do
218
- mod = Puppet::Module.new("mymod")
219
- mod.stubs(:dependencies).returns [
220
- {
221
- "version_requirement" => ">= 2.2.0",
222
- "name" => "baz/satisfied"
223
- },
224
- {
225
- "version_requirement" => "< 2.2.0",
226
- "name" => "baz/alsosatisfied"
285
+ mod = PuppetSpec::Modules.create(
286
+ 'mymod2',
287
+ @modpath,
288
+ :metadata => {
289
+ :dependencies => [
290
+ {
291
+ "version_requirement" => ">= 2.2.0",
292
+ "name" => "baz/satisfied"
293
+ },
294
+ {
295
+ "version_requirement" => "< 2.2.0",
296
+ "name" => "baz/alsosatisfied"
297
+ }
298
+ ]
227
299
  }
228
- ]
229
- satisfied = Puppet::Module.new("satisfied")
230
- satisfied.version = "3.3.0"
231
- alsosatisfied = Puppet::Module.new("alsosatisfied")
232
- alsosatisfied.version = "2.1.0"
233
-
234
- mod.environment.expects(:module).with("satisfied").returns satisfied
235
- mod.environment.expects(:module).with("alsosatisfied").returns alsosatisfied
300
+ )
301
+ PuppetSpec::Modules.create(
302
+ 'satisfied',
303
+ @modpath,
304
+ :metadata => {
305
+ :version => '3.3.0',
306
+ :author => 'baz'
307
+ }
308
+ )
309
+ PuppetSpec::Modules.create(
310
+ 'alsosatisfied',
311
+ @modpath,
312
+ :metadata => {
313
+ :version => '2.1.0',
314
+ :author => 'baz'
315
+ }
316
+ )
236
317
 
237
318
  mod.unmet_dependencies.should be_empty
238
319
  end
@@ -386,6 +467,20 @@ describe Puppet::Module do
386
467
  end
387
468
  end
388
469
 
470
+ describe '#modulepath' do
471
+ it "should return the directory the module is installed in, if a path exists" do
472
+ mod = Puppet::Module.new("foo")
473
+ mod.stubs(:path).returns "/a/foo"
474
+ mod.modulepath.should == '/a'
475
+ end
476
+
477
+ it "should return nil if no path exists" do
478
+ mod = Puppet::Module.new("foo")
479
+ mod.stubs(:path).returns nil
480
+ mod.modulepath.should be_nil
481
+ end
482
+ end
483
+
389
484
  it "should be considered existent if it exists in at least one module path" do
390
485
  mod = Puppet::Module.new("foo")
391
486
  mod.expects(:path).returns "/a/foo"
@@ -658,10 +753,48 @@ describe Puppet::Module do
658
753
  @module.puppetversion.should == @data[:puppetversion]
659
754
  end
660
755
 
756
+ context "when versionRequirement is used for dependency version info" do
757
+ before do
758
+ @data = {
759
+ :license => "GPL2",
760
+ :author => "luke",
761
+ :version => "1.0",
762
+ :source => "http://foo/",
763
+ :puppetversion => "0.25",
764
+ :dependencies => [
765
+ {
766
+ "versionRequirement" => "0.0.1",
767
+ "name" => "pmtacceptance/stdlib"
768
+ },
769
+ {
770
+ "versionRequirement" => "0.1.0",
771
+ "name" => "pmtacceptance/apache"
772
+ }
773
+ ]
774
+ }
775
+ @text = @data.to_pson
776
+
777
+ @module = Puppet::Module.new("foo")
778
+ @module.stubs(:metadata_file).returns "/my/file"
779
+ File.stubs(:read).with("/my/file").returns @text
780
+ end
781
+
782
+ it "should set the dependency version_requirement key" do
783
+ @module.load_metadata
784
+ @module.dependencies[0]['version_requirement'].should == "0.0.1"
785
+ end
786
+
787
+ it "should set the version_requirement key for all dependencies" do
788
+ @module.load_metadata
789
+ @module.dependencies[0]['version_requirement'].should == "0.0.1"
790
+ @module.dependencies[1]['version_requirement'].should == "0.1.0"
791
+ end
792
+ end
793
+
661
794
  it "should fail if the discovered name is different than the metadata name"
662
795
  end
663
796
 
664
- it "should be able to tell if there are local changes" do
797
+ it "should be able to tell if there are local changes", :fails_on_windows => true do
665
798
  modpath = tmpdir('modpath')
666
799
  foo_checksum = 'acbd18db4cc2f85cedef654fccc4a4d8'
667
800
  checksummed_module = PuppetSpec::Modules.create(
@@ -677,12 +810,12 @@ describe Puppet::Module do
677
810
  foo_path = Pathname.new(File.join(checksummed_module.path, 'foo'))
678
811
 
679
812
  IO.binwrite(foo_path, 'notfoo')
680
- Puppet::Module::Tool::Checksums.new(foo_path).checksum(foo_path).should_not == foo_checksum
813
+ Puppet::ModuleTool::Checksums.new(foo_path).checksum(foo_path).should_not == foo_checksum
681
814
  checksummed_module.has_local_changes?.should be_true
682
815
 
683
816
  IO.binwrite(foo_path, 'foo')
684
817
 
685
- Puppet::Module::Tool::Checksums.new(foo_path).checksum(foo_path).should == foo_checksum
818
+ Puppet::ModuleTool::Checksums.new(foo_path).checksum(foo_path).should == foo_checksum
686
819
  checksummed_module.has_local_changes?.should be_false
687
820
  end
688
821