puppet 2.7.3 → 2.7.4

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 (337) hide show
  1. data/CHANGELOG +166 -0
  2. data/install.rb +27 -7
  3. data/lib/puppet/application/agent.rb +29 -29
  4. data/lib/puppet/application/doc.rb +1 -1
  5. data/lib/puppet/application/inspect.rb +9 -1
  6. data/lib/puppet/application/master.rb +2 -0
  7. data/lib/puppet/application/queue.rb +1 -1
  8. data/lib/puppet/application/resource.rb +3 -0
  9. data/lib/puppet/application.rb +4 -5
  10. data/lib/puppet/configurer.rb +1 -4
  11. data/lib/puppet/defaults.rb +45 -15
  12. data/lib/puppet/feature/base.rb +28 -17
  13. data/lib/puppet/feature/rails.rb +0 -3
  14. data/lib/puppet/feature/rubygems.rb +0 -3
  15. data/lib/puppet/file_bucket/dipper.rb +3 -2
  16. data/lib/puppet/file_bucket/file.rb +3 -3
  17. data/lib/puppet/file_serving/base.rb +4 -5
  18. data/lib/puppet/file_serving/configuration.rb +7 -13
  19. data/lib/puppet/file_serving/content.rb +0 -4
  20. data/lib/puppet/file_serving/fileset.rb +7 -6
  21. data/lib/puppet/file_serving/indirection_hooks.rb +1 -4
  22. data/lib/puppet/file_serving/metadata.rb +0 -4
  23. data/lib/puppet/file_serving/mount/file.rb +9 -12
  24. data/lib/puppet/file_serving/mount.rb +0 -5
  25. data/lib/puppet/file_serving/terminus_helper.rb +0 -4
  26. data/lib/puppet/file_serving.rb +0 -4
  27. data/lib/puppet/indirector/catalog/compiler.rb +0 -18
  28. data/lib/puppet/indirector/catalog/store_configs.rb +5 -0
  29. data/lib/puppet/indirector/direct_file_server.rb +0 -4
  30. data/lib/puppet/indirector/facts/facter.rb +2 -2
  31. data/lib/puppet/indirector/facts/store_configs.rb +5 -0
  32. data/lib/puppet/indirector/file_content/file.rb +0 -4
  33. data/lib/puppet/indirector/file_content/file_server.rb +0 -4
  34. data/lib/puppet/indirector/file_content/rest.rb +0 -4
  35. data/lib/puppet/indirector/file_metadata/file.rb +0 -4
  36. data/lib/puppet/indirector/file_metadata/file_server.rb +0 -4
  37. data/lib/puppet/indirector/file_metadata/rest.rb +0 -4
  38. data/lib/puppet/indirector/file_server.rb +1 -5
  39. data/lib/puppet/indirector/indirection.rb +3 -5
  40. data/lib/puppet/indirector/node/store_configs.rb +5 -0
  41. data/lib/puppet/indirector/request.rb +3 -1
  42. data/lib/puppet/indirector/resource/active_record.rb +97 -0
  43. data/lib/puppet/indirector/resource/store_configs.rb +3 -0
  44. data/lib/puppet/indirector/ssl_file.rb +5 -1
  45. data/lib/puppet/indirector/store_configs.rb +30 -0
  46. data/lib/puppet/indirector/yaml.rb +5 -0
  47. data/lib/puppet/indirector.rb +7 -0
  48. data/lib/puppet/network/client.rb +0 -5
  49. data/lib/puppet/network/http_pool.rb +0 -56
  50. data/lib/puppet/node/environment.rb +9 -11
  51. data/lib/puppet/parameter/path.rb +1 -5
  52. data/lib/puppet/parameter.rb +1 -7
  53. data/lib/puppet/parser/ast/collection.rb +2 -2
  54. data/lib/puppet/parser/ast/collexpr.rb +10 -39
  55. data/lib/puppet/parser/collector.rb +41 -90
  56. data/lib/puppet/parser/compiler.rb +0 -3
  57. data/lib/puppet/parser/functions/create_resources.rb +22 -10
  58. data/lib/puppet/parser/functions/versioncmp.rb +9 -6
  59. data/lib/puppet/parser/resource.rb +1 -1
  60. data/lib/puppet/parser/type_loader.rb +2 -1
  61. data/lib/puppet/provider/augeas/augeas.rb +5 -3
  62. data/lib/puppet/provider/cron/crontab.rb +2 -2
  63. data/lib/puppet/provider/exec/posix.rb +23 -96
  64. data/lib/puppet/provider/exec/shell.rb +11 -2
  65. data/lib/puppet/provider/exec/windows.rb +35 -0
  66. data/lib/puppet/provider/exec.rb +79 -0
  67. data/lib/puppet/provider/group/windows_adsi.rb +48 -0
  68. data/lib/puppet/provider/host/parsed.rb +3 -0
  69. data/lib/puppet/provider/macauthorization/macauthorization.rb +4 -4
  70. data/lib/puppet/provider/mount.rb +0 -3
  71. data/lib/puppet/provider/naginator.rb +0 -3
  72. data/lib/puppet/provider/package/appdmg.rb +0 -1
  73. data/lib/puppet/provider/package/apple.rb +3 -7
  74. data/lib/puppet/provider/package/apt.rb +0 -1
  75. data/lib/puppet/provider/package/aptitude.rb +0 -1
  76. data/lib/puppet/provider/package/aptrpm.rb +0 -1
  77. data/lib/puppet/provider/package/blastwave.rb +0 -1
  78. data/lib/puppet/provider/package/dpkg.rb +5 -6
  79. data/lib/puppet/provider/package/fink.rb +3 -4
  80. data/lib/puppet/provider/package/freebsd.rb +0 -1
  81. data/lib/puppet/provider/package/gem.rb +0 -1
  82. data/lib/puppet/provider/package/hpux.rb +3 -3
  83. data/lib/puppet/provider/package/macports.rb +0 -1
  84. data/lib/puppet/provider/package/msi.rb +82 -0
  85. data/lib/puppet/provider/package/openbsd.rb +18 -19
  86. data/lib/puppet/provider/package/pip.rb +0 -1
  87. data/lib/puppet/provider/package/pkg.rb +0 -1
  88. data/lib/puppet/provider/package/pkgdmg.rb +9 -7
  89. data/lib/puppet/provider/package/pkgutil.rb +0 -1
  90. data/lib/puppet/provider/package/ports.rb +0 -1
  91. data/lib/puppet/provider/package/portupgrade.rb +183 -193
  92. data/lib/puppet/provider/package/rpm.rb +1 -1
  93. data/lib/puppet/provider/package/sun.rb +0 -1
  94. data/lib/puppet/provider/package/sunfreeware.rb +0 -2
  95. data/lib/puppet/provider/package/up2date.rb +0 -1
  96. data/lib/puppet/provider/package/urpmi.rb +0 -1
  97. data/lib/puppet/provider/package/yum.rb +1 -1
  98. data/lib/puppet/provider/package.rb +4 -3
  99. data/lib/puppet/provider/service/systemd.rb +64 -0
  100. data/lib/puppet/provider/service/windows.rb +110 -0
  101. data/lib/puppet/provider/user/windows_adsi.rb +71 -0
  102. data/lib/puppet/rails/resource.rb +1 -1
  103. data/lib/puppet/relationship.rb +0 -3
  104. data/lib/puppet/reports/tagmail.rb +15 -11
  105. data/lib/puppet/resource/catalog.rb +17 -24
  106. data/lib/puppet/ssl/certificate_authority.rb +7 -5
  107. data/lib/puppet/ssl/host.rb +6 -10
  108. data/lib/puppet/type/augeas.rb +19 -13
  109. data/lib/puppet/type/cron.rb +13 -12
  110. data/lib/puppet/type/exec.rb +17 -17
  111. data/lib/puppet/type/file/content.rb +7 -3
  112. data/lib/puppet/type/file/source.rb +14 -9
  113. data/lib/puppet/type/file.rb +44 -23
  114. data/lib/puppet/type/filebucket.rb +13 -5
  115. data/lib/puppet/type/package.rb +14 -1
  116. data/lib/puppet/type/service.rb +11 -1
  117. data/lib/puppet/type/ssh_authorized_key.rb +3 -1
  118. data/lib/puppet/type.rb +8 -17
  119. data/lib/puppet/util/adsi.rb +278 -0
  120. data/lib/puppet/util/autoload.rb +0 -2
  121. data/lib/puppet/util/cacher.rb +15 -67
  122. data/lib/puppet/util/feature.rb +0 -3
  123. data/lib/puppet/util/graph.rb +0 -3
  124. data/lib/puppet/util/ldap/connection.rb +0 -3
  125. data/lib/puppet/util/ldap/generator.rb +0 -3
  126. data/lib/puppet/util/ldap.rb +0 -3
  127. data/lib/puppet/util/log_paths.rb +0 -3
  128. data/lib/puppet/util/network_device/cisco/device.rb +2 -1
  129. data/lib/puppet/util/network_device/cisco/facts.rb +1 -1
  130. data/lib/puppet/util/pidlock.rb +5 -1
  131. data/lib/puppet/util/rdoc/parser.rb +3 -1
  132. data/lib/puppet/util/run_mode.rb +2 -2
  133. data/lib/puppet/util/settings/file_setting.rb +3 -2
  134. data/lib/puppet/util/settings.rb +4 -6
  135. data/lib/puppet/util/suidmanager.rb +62 -15
  136. data/lib/puppet/util.rb +113 -131
  137. data/lib/puppet.rb +1 -1
  138. data/spec/integration/application/doc_spec.rb +1 -1
  139. data/spec/integration/defaults_spec.rb +22 -17
  140. data/spec/integration/file_serving/content_spec.rb +0 -6
  141. data/spec/integration/file_serving/metadata_spec.rb +0 -6
  142. data/spec/integration/file_serving/terminus_helper_spec.rb +1 -1
  143. data/spec/integration/indirector/direct_file_server_spec.rb +5 -7
  144. data/spec/integration/indirector/file_content/file_server_spec.rb +2 -6
  145. data/spec/integration/indirector/file_metadata/file_server_spec.rb +1 -5
  146. data/spec/integration/network/server/webrick_spec.rb +6 -9
  147. data/spec/integration/node/facts_spec.rb +0 -6
  148. data/spec/integration/node_spec.rb +3 -4
  149. data/spec/integration/parser/compiler_spec.rb +2 -1
  150. data/spec/integration/parser/parser_spec.rb +2 -4
  151. data/spec/integration/provider/mount_spec.rb +1 -1
  152. data/spec/integration/provider/package_spec.rb +13 -3
  153. data/spec/integration/provider/ssh_authorized_key_spec.rb +4 -4
  154. data/spec/integration/reports_spec.rb +0 -4
  155. data/spec/integration/resource/catalog_spec.rb +0 -5
  156. data/spec/integration/ssl/certificate_authority_spec.rb +6 -14
  157. data/spec/integration/ssl/certificate_request_spec.rb +10 -17
  158. data/spec/integration/ssl/certificate_revocation_list_spec.rb +8 -13
  159. data/spec/integration/ssl/host_spec.rb +8 -14
  160. data/spec/integration/transaction/report_spec.rb +0 -5
  161. data/spec/integration/transaction_spec.rb +11 -13
  162. data/spec/integration/type/file_spec.rb +16 -16
  163. data/spec/integration/type/tidy_spec.rb +1 -1
  164. data/spec/integration/util/settings_spec.rb +2 -2
  165. data/spec/integration/util_spec.rb +13 -0
  166. data/spec/lib/puppet_spec/files.rb +18 -10
  167. data/spec/shared_behaviours/file_server_terminus.rb +1 -5
  168. data/spec/shared_behaviours/file_serving.rb +0 -4
  169. data/spec/shared_behaviours/memory_terminus.rb +0 -4
  170. data/spec/shared_behaviours/path_parameters.rb +20 -18
  171. data/spec/shared_behaviours/store_configs_terminus.rb +21 -0
  172. data/spec/spec_helper.rb +31 -0
  173. data/spec/unit/agent_spec.rb +0 -4
  174. data/spec/unit/application/apply_spec.rb +8 -2
  175. data/spec/unit/application/certificate_spec.rb +2 -0
  176. data/spec/unit/application/device_spec.rb +8 -6
  177. data/spec/unit/application/inspect_spec.rb +2 -1
  178. data/spec/unit/application/master_spec.rb +7 -2
  179. data/spec/unit/application/queue_spec.rb +3 -4
  180. data/spec/unit/application/resource_spec.rb +26 -0
  181. data/spec/unit/application/secret_agent_spec.rb +3 -1
  182. data/spec/unit/application_spec.rb +4 -0
  183. data/spec/unit/configurer/downloader_spec.rb +4 -3
  184. data/spec/unit/configurer_spec.rb +11 -4
  185. data/spec/unit/daemon_spec.rb +3 -1
  186. data/spec/unit/face/ca_spec.rb +1 -1
  187. data/spec/unit/face/node_spec.rb +5 -1
  188. data/spec/unit/face/secret_agent_spec.rb +3 -1
  189. data/spec/unit/file_bucket/dipper_spec.rb +4 -4
  190. data/spec/unit/file_bucket/file_spec.rb +9 -3
  191. data/spec/unit/file_serving/configuration_spec.rb +26 -37
  192. data/spec/unit/file_serving/fileset_spec.rb +71 -55
  193. data/spec/unit/file_serving/indirection_hooks_spec.rb +0 -4
  194. data/spec/unit/file_serving/mount/file_spec.rb +163 -169
  195. data/spec/unit/file_serving/terminus_helper_spec.rb +0 -4
  196. data/spec/unit/indirector/catalog/compiler_spec.rb +0 -22
  197. data/spec/unit/indirector/catalog/store_configs_spec.rb +17 -0
  198. data/spec/unit/indirector/certificate/ca_spec.rb +0 -4
  199. data/spec/unit/indirector/certificate/file_spec.rb +0 -4
  200. data/spec/unit/indirector/certificate_request/ca_spec.rb +1 -5
  201. data/spec/unit/indirector/certificate_request/file_spec.rb +0 -4
  202. data/spec/unit/indirector/certificate_revocation_list/ca_spec.rb +0 -4
  203. data/spec/unit/indirector/certificate_revocation_list/file_spec.rb +0 -4
  204. data/spec/unit/indirector/certificate_status/file_spec.rb +1 -1
  205. data/spec/unit/indirector/direct_file_server_spec.rb +0 -4
  206. data/spec/unit/indirector/facts/facter_spec.rb +0 -4
  207. data/spec/unit/indirector/facts/inventory_active_record_spec.rb +3 -0
  208. data/spec/unit/indirector/facts/store_configs_spec.rb +17 -0
  209. data/spec/unit/indirector/file_bucket_file/file_spec.rb +3 -3
  210. data/spec/unit/indirector/file_content/file_server_spec.rb +0 -4
  211. data/spec/unit/indirector/file_content/file_spec.rb +0 -4
  212. data/spec/unit/indirector/file_metadata/file_server_spec.rb +0 -4
  213. data/spec/unit/indirector/file_metadata/file_spec.rb +0 -4
  214. data/spec/unit/indirector/file_server_spec.rb +1 -5
  215. data/spec/unit/indirector/indirection_spec.rb +0 -4
  216. data/spec/unit/indirector/key/ca_spec.rb +0 -4
  217. data/spec/unit/indirector/key/file_spec.rb +0 -4
  218. data/spec/unit/indirector/node/store_configs_spec.rb +16 -0
  219. data/spec/unit/indirector/report/processor_spec.rb +0 -4
  220. data/spec/unit/indirector/resource/active_record_spec.rb +192 -0
  221. data/spec/unit/indirector/resource/ral_spec.rb +1 -1
  222. data/spec/unit/indirector/resource/store_configs_spec.rb +12 -0
  223. data/spec/unit/indirector/resource_type/parser_spec.rb +3 -3
  224. data/spec/unit/indirector/ssl_file_spec.rb +25 -6
  225. data/spec/unit/indirector/store_configs_spec.rb +8 -0
  226. data/spec/unit/indirector/yaml_spec.rb +14 -0
  227. data/spec/unit/module_spec.rb +2 -2
  228. data/spec/unit/network/handler/fileserver_spec.rb +5 -5
  229. data/spec/unit/network/http/mongrel_spec.rb +0 -4
  230. data/spec/unit/network/http/webrick_spec.rb +5 -9
  231. data/spec/unit/network/http_pool_spec.rb +4 -75
  232. data/spec/unit/network/http_spec.rb +0 -4
  233. data/spec/unit/network/server_spec.rb +0 -4
  234. data/spec/unit/node/environment_spec.rb +18 -31
  235. data/spec/unit/node/facts_spec.rb +0 -4
  236. data/spec/unit/node_spec.rb +1 -8
  237. data/spec/unit/other/selinux_spec.rb +3 -1
  238. data/spec/unit/parameter_spec.rb +0 -10
  239. data/spec/unit/parser/ast/collexpr_spec.rb +17 -13
  240. data/spec/unit/parser/collector_spec.rb +147 -263
  241. data/spec/unit/parser/compiler_spec.rb +3 -1
  242. data/spec/unit/parser/files_spec.rb +7 -4
  243. data/spec/unit/parser/functions/extlookup_spec.rb +6 -3
  244. data/spec/unit/parser/functions/sprintf_spec.rb +2 -1
  245. data/spec/unit/parser/type_loader_spec.rb +7 -7
  246. data/spec/unit/property_spec.rb +1 -1
  247. data/spec/unit/provider/augeas/augeas_spec.rb +14 -0
  248. data/spec/unit/provider/exec/posix_spec.rb +102 -106
  249. data/spec/unit/provider/exec/shell_spec.rb +1 -1
  250. data/spec/unit/provider/exec/windows_spec.rb +119 -0
  251. data/spec/unit/provider/group/ldap_spec.rb +0 -4
  252. data/spec/unit/provider/group/windows_adsi_spec.rb +79 -0
  253. data/spec/unit/provider/ldap_spec.rb +0 -4
  254. data/spec/unit/provider/macauthorization_spec.rb +5 -0
  255. data/spec/unit/provider/mount/parsed_spec.rb +1 -5
  256. data/spec/unit/provider/package/msi_spec.rb +170 -0
  257. data/spec/unit/provider/service/redhat_spec.rb +2 -0
  258. data/spec/unit/provider/service/smf_spec.rb +3 -0
  259. data/spec/unit/provider/service/systemd_spec.rb +25 -0
  260. data/spec/unit/provider/service/windows_spec.rb +166 -0
  261. data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +2 -2
  262. data/spec/unit/provider/user/ldap_spec.rb +0 -4
  263. data/spec/unit/provider/user/user_role_add_spec.rb +1 -1
  264. data/spec/unit/provider/user/useradd_spec.rb +1 -1
  265. data/spec/unit/provider/user/windows_adsi_spec.rb +110 -0
  266. data/spec/unit/relationship_spec.rb +0 -4
  267. data/spec/unit/resource/catalog_spec.rb +37 -25
  268. data/spec/unit/resource/status_spec.rb +4 -2
  269. data/spec/unit/resource_spec.rb +5 -5
  270. data/spec/unit/simple_graph_spec.rb +0 -4
  271. data/spec/unit/ssl/certificate_authority_spec.rb +2 -2
  272. data/spec/unit/ssl/host_spec.rb +12 -13
  273. data/spec/unit/ssl/inventory_spec.rb +2 -2
  274. data/spec/unit/sslcertificates/ca_spec.rb +6 -10
  275. data/spec/unit/transaction/event_manager_spec.rb +4 -2
  276. data/spec/unit/transaction/event_spec.rb +3 -1
  277. data/spec/unit/transaction/report_spec.rb +2 -6
  278. data/spec/unit/transaction/resource_harness_spec.rb +9 -5
  279. data/spec/unit/transaction_spec.rb +3 -1
  280. data/spec/unit/type/cron_spec.rb +1 -1
  281. data/spec/unit/type/exec_spec.rb +80 -47
  282. data/spec/unit/type/file/checksum_spec.rb +9 -8
  283. data/spec/unit/type/file/content_spec.rb +2 -1
  284. data/spec/unit/type/file/selinux_spec.rb +10 -8
  285. data/spec/unit/type/file/source_spec.rb +18 -36
  286. data/spec/unit/type/file_spec.rb +170 -217
  287. data/spec/unit/type/group_spec.rb +1 -1
  288. data/spec/unit/type/mount_spec.rb +5 -5
  289. data/spec/unit/type/noop_metaparam_spec.rb +3 -1
  290. data/spec/unit/type/package_spec.rb +15 -3
  291. data/spec/unit/type/resources_spec.rb +2 -2
  292. data/spec/unit/type/service_spec.rb +19 -4
  293. data/spec/unit/type/ssh_authorized_key_spec.rb +10 -4
  294. data/spec/unit/type/tidy_spec.rb +3 -1
  295. data/spec/unit/type/user_spec.rb +1 -1
  296. data/spec/unit/type_spec.rb +29 -34
  297. data/spec/unit/util/adsi_spec.rb +202 -0
  298. data/spec/unit/util/autoload_spec.rb +23 -19
  299. data/spec/unit/util/backups_spec.rb +16 -13
  300. data/spec/unit/util/cacher_spec.rb +64 -141
  301. data/spec/unit/util/checksums_spec.rb +0 -4
  302. data/spec/unit/util/constant_inflector_spec.rb +0 -4
  303. data/spec/unit/util/execution_stub_spec.rb +1 -1
  304. data/spec/unit/util/ldap/connection_spec.rb +0 -4
  305. data/spec/unit/util/ldap/generator_spec.rb +0 -4
  306. data/spec/unit/util/ldap/manager_spec.rb +0 -4
  307. data/spec/unit/util/log_spec.rb +4 -2
  308. data/spec/unit/util/logging_spec.rb +2 -2
  309. data/spec/unit/util/nagios_maker_spec.rb +0 -4
  310. data/spec/unit/util/network_device/cisco/device_spec.rb +2 -1
  311. data/spec/unit/util/network_device/cisco/facts_spec.rb +3 -1
  312. data/spec/unit/util/network_device/config_spec.rb +5 -3
  313. data/spec/unit/util/rdoc/parser_spec.rb +7 -1
  314. data/spec/unit/util/run_mode_spec.rb +6 -2
  315. data/spec/unit/util/settings/file_setting_spec.rb +29 -2
  316. data/spec/unit/util/settings_spec.rb +28 -15
  317. data/spec/unit/util/storage_spec.rb +1 -1
  318. data/spec/unit/util/suidmanager_spec.rb +310 -0
  319. data/spec/unit/util/tagging_spec.rb +0 -4
  320. data/spec/unit/util_spec.rb +335 -0
  321. data/test/language/ast/variable.rb +0 -4
  322. data/test/lib/puppettest/support/resources.rb +0 -4
  323. data/test/lib/puppettest/testcase.rb +0 -4
  324. data/test/lib/puppettest.rb +0 -1
  325. data/test/network/handler/master.rb +0 -5
  326. data/test/network/server/webrick.rb +5 -22
  327. data/test/ral/manager/attributes.rb +0 -4
  328. data/test/ral/manager/instances.rb +0 -4
  329. data/test/ral/manager/manager.rb +0 -4
  330. data/test/ral/providers/cron/crontab.rb +1 -0
  331. data/test/ral/providers/service/base.rb +0 -4
  332. data/test/ral/type/filesources.rb +0 -1
  333. data/test/ral/type/resources.rb +0 -4
  334. data/test/util/utiltest.rb +0 -13
  335. metadata +36 -9
  336. data/spec/unit/network/client_spec.rb +0 -45
  337. data/test/puppet/tc_suidmanager.rb +0 -120
@@ -1,6 +1,8 @@
1
1
  #!/usr/bin/env rspec
2
2
  require 'spec_helper'
3
3
 
4
+ require 'tmpdir'
5
+
4
6
  require 'puppet/node/environment'
5
7
  require 'puppet/util/execution'
6
8
 
@@ -10,10 +12,6 @@ describe Puppet::Node::Environment do
10
12
  Puppet::Node::Environment.clear
11
13
  end
12
14
 
13
- it "should include the Cacher module" do
14
- Puppet::Node::Environment.ancestors.should be_include(Puppet::Util::Cacher)
15
- end
16
-
17
15
  it "should use the filetimeout for the ttl for the modulepath" do
18
16
  Puppet::Node::Environment.attr_ttl(:modulepath).should == Integer(Puppet[:filetimeout])
19
17
  end
@@ -22,10 +20,6 @@ describe Puppet::Node::Environment do
22
20
  Puppet::Node::Environment.attr_ttl(:modules).should == Integer(Puppet[:filetimeout])
23
21
  end
24
22
 
25
- it "should use the filetimeout for the ttl for the manifestdir" do
26
- Puppet::Node::Environment.attr_ttl(:manifestdir).should == Integer(Puppet[:filetimeout])
27
- end
28
-
29
23
  it "should use the default environment if no name is provided while initializing an environment" do
30
24
  Puppet.settings.expects(:value).with(:environment).returns("one")
31
25
  Puppet::Node::Environment.new.name.should == :one
@@ -109,27 +103,15 @@ describe Puppet::Node::Environment do
109
103
  end
110
104
  end
111
105
 
112
- [:modulepath, :manifestdir].each do |setting|
113
- it "should validate the #{setting} directories" do
114
- path = %w{/one /two}.join(File::PATH_SEPARATOR)
115
-
116
- env = Puppet::Node::Environment.new("testing")
117
- env.stubs(:[]).with(setting).returns path
118
-
119
- env.expects(:validate_dirs).with(%w{/one /two})
120
-
121
- env.send(setting)
122
- end
106
+ it "should validate the modulepath directories" do
107
+ real_file = tmpdir('moduledir')
108
+ path = %W[/one /two #{real_file}].join(File::PATH_SEPARATOR)
123
109
 
124
- it "should return the validated dirs for #{setting}" do
125
- path = %w{/one /two}.join(File::PATH_SEPARATOR)
110
+ Puppet[:modulepath] = path
126
111
 
127
- env = Puppet::Node::Environment.new("testing")
128
- env.stubs(:[]).with(setting).returns path
129
- env.stubs(:validate_dirs).returns %w{/one /two}
112
+ env = Puppet::Node::Environment.new("testing")
130
113
 
131
- env.send(setting).should == %w{/one /two}
132
- end
114
+ env.modulepath.should == [real_file]
133
115
  end
134
116
 
135
117
  it "should prefix the value of the 'PUPPETLIB' environment variable to the module path if present" do
@@ -144,21 +126,26 @@ describe Puppet::Node::Environment do
144
126
  end
145
127
 
146
128
  describe "when validating modulepath or manifestdir directories" do
129
+ before :each do
130
+ @path_one = make_absolute('/one')
131
+ @path_two = make_absolute('/two')
132
+ end
133
+
147
134
  it "should not return non-directories" do
148
135
  env = Puppet::Node::Environment.new("testing")
149
136
 
150
- FileTest.expects(:directory?).with("/one").returns true
151
- FileTest.expects(:directory?).with("/two").returns false
137
+ FileTest.expects(:directory?).with(@path_one).returns true
138
+ FileTest.expects(:directory?).with(@path_two).returns false
152
139
 
153
- env.validate_dirs(%w{/one /two}).should == %w{/one}
140
+ env.validate_dirs([@path_one, @path_two]).should == [@path_one]
154
141
  end
155
142
 
156
143
  it "should use the current working directory to fully-qualify unqualified paths" do
157
144
  FileTest.stubs(:directory?).returns true
158
145
  env = Puppet::Node::Environment.new("testing")
159
146
 
160
- two = File.join(Dir.getwd, "two")
161
- env.validate_dirs(%w{/one two}).should == ["/one", two]
147
+ two = File.expand_path(File.join(Dir.getwd, "two"))
148
+ env.validate_dirs([@path_one, 'two']).should == [@path_one, two]
162
149
  end
163
150
  end
164
151
 
@@ -68,10 +68,6 @@ describe Puppet::Node::Facts, "when indirecting" do
68
68
  before do
69
69
  @indirection = stub 'indirection', :request => mock('request'), :name => :facts
70
70
 
71
- # We have to clear the cache so that the facts ask for our indirection stub,
72
- # instead of anything that might be cached.
73
- Puppet::Util::Cacher.expire
74
-
75
71
  @facts = Puppet::Node::Facts.new("me", "one" => "two")
76
72
  end
77
73
 
@@ -130,15 +130,8 @@ end
130
130
  describe Puppet::Node, "when indirecting" do
131
131
  it "should default to the 'plain' node terminus" do
132
132
  Puppet::Node.indirection.reset_terminus_class
133
- Puppet::Node.indirection.terminus_class.should == :plain
134
- end
135
133
 
136
- it "should not have a cache class defined" do
137
- Puppet::Node.indirection.cache_class.should be_nil
138
- end
139
-
140
- after do
141
- Puppet::Util::Cacher.expire
134
+ Puppet::Node.indirection.terminus_class.should == :plain
142
135
  end
143
136
  end
144
137
 
@@ -5,11 +5,13 @@ require 'puppet/type/selboolean'
5
5
  require 'puppet/type/selmodule'
6
6
 
7
7
  describe Puppet::Type.type(:file), " when manipulating file contexts" do
8
+ include PuppetSpec::Files
9
+
8
10
  before :each do
9
11
 
10
12
  @file = Puppet::Type::File.new(
11
13
 
12
- :name => "/tmp/foo",
14
+ :name => make_absolute("/tmp/foo"),
13
15
  :ensure => "file",
14
16
  :seluser => "user_u",
15
17
  :selrole => "role_r",
@@ -25,16 +25,6 @@ describe Puppet::Parameter do
25
25
  @parameter.to_s.should == @parameter.name.to_s
26
26
  end
27
27
 
28
- it "should be able to use cached attributes" do
29
- Puppet::Parameter.ancestors.should be_include(Puppet::Util::Cacher)
30
- end
31
-
32
- it "should use the resource catalog for expiration" do
33
- catalog = mock 'catalog'
34
- @resource.stubs(:catalog).returns catalog
35
- @parameter.expirer.should equal(catalog)
36
- end
37
-
38
28
  [:line, :file, :version].each do |data|
39
29
  it "should return its resource's #{data} as its #{data}" do
40
30
  @resource.expects(data).returns "foo"
@@ -18,14 +18,14 @@ describe Puppet::Parser::AST::CollExpr do
18
18
  end
19
19
 
20
20
  it "should evaluate both" do
21
- collexpr = ast::CollExpr.new(:test1 => @test1, :test2 => @test2, :oper=>"==")
21
+ collexpr = ast::CollExpr.new(:test1 => @test1, :test2 => @test2, :oper => "==")
22
22
  collexpr.evaluate(@scope)
23
23
  end
24
24
 
25
- it "should produce a textual representation and code of the expression" do
26
- collexpr = ast::CollExpr.new(:test1 => @test1, :test2 => @test2, :oper=>"==")
25
+ it "should produce a data and code representation of the expression" do
26
+ collexpr = ast::CollExpr.new(:test1 => @test1, :test2 => @test2, :oper => "==")
27
27
  result = collexpr.evaluate(@scope)
28
- result[0].should == "param_values.value = 'test2' and param_names.name = 'test1'"
28
+ result[0].should == ["test1", "==", "test2"]
29
29
  result[1].should be_an_instance_of(Proc)
30
30
  end
31
31
 
@@ -59,16 +59,20 @@ describe Puppet::Parser::AST::CollExpr do
59
59
  end
60
60
  end
61
61
 
62
- it "should warn if this is an exported collection containing parenthesis (unsupported)" do
63
- collexpr = ast::CollExpr.new(:test1 => @test1, :test2 => @test2, :oper=>"==", :parens => true, :form => :exported)
64
- Puppet.expects(:warning)
65
- collexpr.evaluate(@scope)
62
+ it "should work if this is an exported collection containing parenthesis" do
63
+ collexpr = ast::CollExpr.new(:test1 => @test1, :test2 => @test2,
64
+ :oper => "==", :parens => true, :form => :exported)
65
+ match, code = collexpr.evaluate(@scope)
66
+ match.should == ["test1", "==", "test2"]
67
+ @logs.should be_empty # no warnings emitted
66
68
  end
67
69
 
68
70
  %w{and or}.each do |op|
69
- it "should raise an error if this is an exported collection with #{op} operator (unsupported)" do
70
- collexpr = ast::CollExpr.new(:test1 => @test1, :test2 => @test2, :oper=> op, :form => :exported)
71
- lambda { collexpr.evaluate(@scope) }.should raise_error(Puppet::ParseError)
71
+ it "should parse / eval if this is an exported collection with #{op} operator" do
72
+ collexpr = ast::CollExpr.new(:test1 => @test1, :test2 => @test2,
73
+ :oper => op, :form => :exported)
74
+ match, code = collexpr.evaluate(@scope)
75
+ match.should == ["test1", op, "test2"]
72
76
  end
73
77
  end
74
78
  end
@@ -82,10 +86,10 @@ describe Puppet::Parser::AST::CollExpr do
82
86
  @resource.stubs(:tagged?).with("value").returns(true)
83
87
  end
84
88
 
85
- it "should produce a textual representation of the expression" do
89
+ it "should produce a data representation of the expression" do
86
90
  collexpr = ast::CollExpr.new(:test1 => @tag, :test2 => @value, :oper=>"==")
87
91
  result = collexpr.evaluate(@scope)
88
- result[0].should == "puppet_tags.name = 'value'"
92
+ result[0].should == ["tag", "==", "value"]
89
93
  end
90
94
 
91
95
  it "should inspect resource tags if the query term is on tags" do
@@ -1,6 +1,11 @@
1
1
  #!/usr/bin/env rspec
2
2
  require 'spec_helper'
3
3
 
4
+ begin
5
+ require 'sqlite3'
6
+ rescue LoadError
7
+ end
8
+
4
9
  require 'puppet/rails'
5
10
  require 'puppet/parser/collector'
6
11
 
@@ -262,294 +267,173 @@ describe Puppet::Parser::Collector, "when collecting virtual and catalog resourc
262
267
  end
263
268
  end
264
269
 
265
- describe Puppet::Parser::Collector, "when collecting exported resources", :if => Puppet.features.rails? do
270
+ describe Puppet::Parser::Collector, "when collecting exported resources", :if => (Puppet.features.rails? and defined? SQLite3) do
271
+ include PuppetSpec::Files
272
+
266
273
  before do
267
274
  @compiler = Puppet::Parser::Compiler.new(Puppet::Node.new("mynode"))
268
275
  @scope = Puppet::Parser::Scope.new :compiler => @compiler
269
- @resource_type = "Mytype"
270
- @equery = "test = true"
276
+ @resource_type = "notify"
277
+ @equery = ["title", "!=", ""]
271
278
  @vquery = proc { |r| true }
272
-
273
- res = stub("resource 1")
274
- res.stubs(:type).returns @resource_type
275
- Puppet::Resource.stubs(:new).returns res
276
-
277
- Puppet.settings.stubs(:value).with(:storeconfigs).returns true
278
- Puppet.settings.stubs(:value).with(:environment).returns "production"
279
-
280
- @collector = Puppet::Parser::Collector.new(@scope, @resource_type, @equery, @vquery, :exported)
281
- end
282
-
283
- # Stub most of our interface to Rails.
284
- def stub_rails(everything = false)
285
- ActiveRecord::Base.stubs(:connected?).returns(false)
286
- Puppet::Rails.stubs(:init)
287
- if everything
288
- Puppet::Rails::Host.stubs(:find_by_name).returns(nil)
289
- Puppet::Rails::Resource.stubs(:find).returns([])
290
- end
279
+ @collector = Puppet::Parser::Collector.new(@scope, @resource_type,
280
+ @equery, @vquery, :exported)
291
281
  end
292
282
 
293
283
  it "should just return false if :storeconfigs is not enabled" do
294
- Puppet.settings.expects(:value).with(:storeconfigs).returns false
284
+ Puppet[:storeconfigs] = false
295
285
  @collector.evaluate.should be_false
296
286
  end
297
287
 
298
- it "should use initialize the Rails support if ActiveRecord is not connected" do
299
- @compiler.stubs(:resources).returns([])
300
- ActiveRecord::Base.expects(:connected?).returns(false)
301
- Puppet::Rails.expects(:init)
302
- Puppet::Rails::Host.stubs(:find_by_name).returns(nil)
303
- Puppet::Rails::Resource.stubs(:find).returns([])
304
-
305
- @collector.evaluate
306
- end
307
-
308
- it "should return all matching resources from the current compile and mark them non-virtual and non-exported" do
309
- stub_rails(true)
310
-
311
- one = stub 'one', :type => "Mytype", :virtual? => true, :exported? => true, :ref => "one"
312
- two = stub 'two', :type => "Mytype", :virtual? => true, :exported? => true, :ref => "two"
313
-
314
- one.stubs(:exported=)
315
- one.stubs(:virtual=)
316
- two.stubs(:exported=)
317
- two.stubs(:virtual=)
318
-
319
- @compiler.expects(:resources).returns([one, two])
320
-
321
- @collector.evaluate.should == [one, two]
322
- end
323
-
324
- it "should mark all returned resources as not virtual" do
325
- stub_rails(true)
326
-
327
- one = stub 'one', :type => "Mytype", :virtual? => true, :exported? => true, :ref => "one"
328
-
329
- one.stubs(:exported=)
330
- one.expects(:virtual=).with(false)
331
-
332
- @compiler.expects(:resources).returns([one])
333
-
334
- @collector.evaluate.should == [one]
335
- end
336
-
337
- it "should convert all found resources into parser resources" do
338
- stub_rails
339
- Puppet::Rails::Host.stubs(:find_by_name).returns(nil)
340
-
341
- one = stub 'one', :restype => "Mytype", :title => "one", :virtual? => true, :exported? => true, :ref => "one"
342
- Puppet::Rails::Resource.stubs(:find).returns([one])
343
-
344
- resource = mock 'resource'
345
- one.expects(:to_resource).with(@scope).returns(resource)
346
- resource.stubs(:exported=)
347
- resource.stubs(:virtual=)
348
- resource.stubs(:ref)
349
-
350
- @compiler.stubs(:resources).returns([])
351
- @scope.stubs(:findresource).returns(nil)
352
-
353
- @compiler.stubs(:add_resource)
354
-
355
- @collector.evaluate.should == [resource]
356
- end
357
-
358
- it "should override all exported collected resources if collector has an override" do
359
- stub_rails
360
- Puppet::Rails::Host.stubs(:find_by_name).returns(nil)
361
-
362
- one = stub 'one', :restype => "Mytype", :title => "one", :virtual? => true, :exported? => true, :ref => "one"
363
- Puppet::Rails::Resource.stubs(:find).returns([one])
364
-
365
- resource = mock 'resource', :type => "Mytype"
366
- one.expects(:to_resource).with(@scope).returns(resource)
367
- resource.stubs(:exported=)
368
- resource.stubs(:virtual=)
369
- resource.stubs(:ref)
370
- resource.stubs(:title)
371
-
372
- @compiler.stubs(:resources).returns([])
373
- @scope.stubs(:findresource).returns(nil)
374
-
375
- param = stub 'param'
376
- @compiler.stubs(:add_override)
377
- @compiler.stubs(:add_resource)
378
-
379
- @collector.add_override(:parameters => param )
380
- Puppet::Parser::Resource.expects(:new).once.with { |type, title, h|
381
- h[:parameters] == param
382
- }
383
-
384
- @collector.evaluate
385
- end
386
-
387
- it "should store converted resources in the compile's resource list" do
388
- stub_rails
389
- Puppet::Rails::Host.stubs(:find_by_name).returns(nil)
390
-
391
- one = stub 'one', :restype => "Mytype", :title => "one", :virtual? => true, :exported? => true, :ref => "one"
392
- Puppet::Rails::Resource.stubs(:find).returns([one])
393
-
394
- resource = mock 'resource'
395
- one.expects(:to_resource).with(@scope).returns(resource)
396
- resource.stubs(:exported=)
397
- resource.stubs(:virtual=)
398
- resource.stubs(:ref)
399
-
400
- @compiler.stubs(:resources).returns([])
401
- @scope.stubs(:findresource).returns(nil)
402
-
403
- @compiler.expects(:add_resource).with(@scope, resource)
404
-
405
- @collector.evaluate.should == [resource]
406
- end
407
-
408
- # This way one host doesn't store another host's resources as exported.
409
- it "should mark resources collected from the database as not exported" do
410
- stub_rails
411
- Puppet::Rails::Host.stubs(:find_by_name).returns(nil)
412
-
413
- one = stub 'one', :restype => "Mytype", :title => "one", :virtual? => true, :exported? => true, :ref => "one"
414
- Puppet::Rails::Resource.stubs(:find).returns([one])
415
-
416
- resource = mock 'resource'
417
- one.expects(:to_resource).with(@scope).returns(resource)
418
- resource.expects(:exported=).with(false)
419
- resource.stubs(:virtual=)
420
- resource.stubs(:ref)
421
-
422
- @compiler.stubs(:resources).returns([])
423
- @scope.stubs(:findresource).returns(nil)
424
-
425
- @compiler.stubs(:add_resource)
426
-
427
- @collector.evaluate
428
- end
429
-
430
- it "should fail if an equivalent resource already exists in the compile" do
431
- stub_rails
432
- Puppet::Rails::Host.stubs(:find_by_name).returns(nil)
433
-
434
- rails = stub 'one', :restype => "Mytype", :title => "one", :virtual? => true, :exported? => true, :id => 1, :ref => "yay"
435
- inmemory = stub 'one', :type => "Mytype", :virtual? => true, :exported? => true, :rails_id => 2
436
-
437
- Puppet::Rails::Resource.stubs(:find).returns([rails])
438
-
439
- resource = mock 'resource'
440
-
441
- @compiler.stubs(:resources).returns([])
442
- @scope.stubs(:findresource).returns(inmemory)
443
-
444
- @compiler.stubs(:add_resource)
445
-
446
- proc { @collector.evaluate }.should raise_error(Puppet::ParseError)
447
- end
448
-
449
- it "should ignore exported resources that match already-collected resources" do
450
- stub_rails
451
- Puppet::Rails::Host.stubs(:find_by_name).returns(nil)
288
+ context "with storeconfigs enabled" do
289
+ before :each do
290
+ ActiveRecord::Base.remove_connection
452
291
 
453
- rails = stub 'one', :restype => "Mytype", :title => "one", :virtual? => true, :exported? => true, :id => 1, :ref => "yay"
454
- inmemory = stub 'one', :type => "Mytype", :virtual? => true, :exported? => true, :rails_id => 1
455
-
456
- Puppet::Rails::Resource.stubs(:find).returns([rails])
457
-
458
- resource = mock 'resource'
459
-
460
- @compiler.stubs(:resources).returns([])
461
- @scope.stubs(:findresource).returns(inmemory)
462
-
463
- @compiler.stubs(:add_resource)
464
-
465
- proc { @collector.evaluate }.should_not raise_error(Puppet::ParseError)
466
- end
467
- end
468
-
469
- describe Puppet::Parser::Collector, "when building its ActiveRecord query for collecting exported resources", :if => Puppet.features.rails? do
470
- before do
471
- @scope = stub 'scope', :host => "myhost", :debug => nil
472
- @compiler = mock 'compile'
473
- @scope.stubs(:compiler).returns(@compiler)
474
- @resource_type = "Mytype"
475
- @equery = nil
476
- @vquery = proc { |r| true }
477
-
478
- @resource = stub_everything 'collected'
479
-
480
- @collector = Puppet::Parser::Collector.new(@scope, @resource_type, @equery, @vquery, :exported)
481
- @collector.stubs(:exported_resource).with(@resource).returns(@resource)
482
- @compiler.stubs(:resources).returns([])
483
-
484
- ActiveRecord::Base.stubs(:connected?).returns(false)
485
-
486
- Puppet::Rails.stubs(:init)
487
- Puppet::Rails::Host.stubs(:find_by_name).returns(nil)
488
- Puppet::Rails::Resource.stubs(:find).returns([])
292
+ dir = Pathname(tmpdir('puppet-var'))
293
+ Puppet[:vardir] = dir.to_s
294
+ Puppet[:dbadapter] = 'sqlite3'
295
+ Puppet[:dblocation] = (dir + 'storeconfigs.sqlite').to_s
296
+ Puppet[:storeconfigs] = true
297
+ Puppet[:environment] = "production"
298
+ Puppet::Rails.init
299
+ end
489
300
 
490
- Puppet.settings.stubs(:value).with(:storeconfigs).returns true
491
- end
301
+ after :each do
302
+ ActiveRecord::Base.remove_connection
303
+ end
492
304
 
493
- it "should exclude all resources from the host if ActiveRecord contains information for this host" do
494
- @host = mock 'host'
495
- @host.stubs(:id).returns 5
305
+ it "should return all matching resources from the current compile and mark them non-virtual and non-exported" do
306
+ one = Puppet::Parser::Resource.new('notify', 'one',
307
+ :virtual => true,
308
+ :exported => true,
309
+ :scope => @scope)
310
+ two = Puppet::Parser::Resource.new('notify', 'two',
311
+ :virtual => true,
312
+ :exported => true,
313
+ :scope => @scope)
314
+
315
+ @compiler.resources << one
316
+ @compiler.resources << two
317
+
318
+ @collector.evaluate.should == [one, two]
319
+ one.should_not be_virtual
320
+ two.should_not be_virtual
321
+
322
+ # REVISIT: Apparently we never actually marked local resources as
323
+ # non-exported. So, this is what the previous test asserted, and checking
324
+ # what it claims to do causes test failures. --daniel 2011-08-23
325
+ end
496
326
 
497
- Puppet::Rails::Host.expects(:find_by_name).with(@scope.host).returns(@host)
327
+ it "should mark all returned resources as not virtual" do
328
+ one = Puppet::Parser::Resource.new('notify', 'one',
329
+ :virtual => true,
330
+ :exported => true,
331
+ :scope => @scope)
498
332
 
499
- Puppet::Rails::Resource.stubs(:find).with { |*arguments|
500
- options = arguments[1]
501
- options[:conditions][0] =~ /^host_id != \?/ and options[:conditions][1] == 5
502
- }.returns([@resource])
333
+ @compiler.resources << one
503
334
 
504
- @collector.evaluate.should == [@resource]
505
- end
335
+ @collector.evaluate.should == [one]
336
+ one.should_not be_virtual
337
+ end
506
338
 
507
- it "should join with parameter names, parameter values when querying ActiveRecord" do
508
- @collector.equery = "param_names.name = title"
509
- Puppet::Rails::Resource.stubs(:find).with { |*arguments|
510
- options = arguments[1]
511
- options[:joins] == {:param_values => :param_name}
512
- }.returns([@resource])
339
+ it "should convert all found resources into parser resources" do
340
+ host = Puppet::Rails::Host.create!(:name => 'one.local')
341
+ Puppet::Rails::Resource.
342
+ create!(:host => host,
343
+ :restype => 'notify', :title => 'whammo',
344
+ :exported => true)
345
+
346
+ result = @collector.evaluate
347
+ result.length.should == 1
348
+ result.first.should be_an_instance_of Puppet::Parser::Resource
349
+ result.first.type.should == 'Notify'
350
+ result.first.title.should == 'whammo'
351
+ end
513
352
 
514
- @collector.evaluate.should == [@resource]
515
- end
353
+ it "should override all exported collected resources if collector has an override" do
354
+ host = Puppet::Rails::Host.create!(:name => 'one.local')
355
+ Puppet::Rails::Resource.
356
+ create!(:host => host,
357
+ :restype => 'notify', :title => 'whammo',
358
+ :exported => true)
516
359
 
517
- it "should join with tag tables when querying ActiveRecord with a tag exported query" do
518
- @collector.equery = "puppet_tags.name = test"
519
- Puppet::Rails::Resource.stubs(:find).with { |*arguments|
520
- options = arguments[1]
521
- options[:joins] == {:resource_tags => :puppet_tag}
522
- }.returns([@resource])
360
+ param = Puppet::Parser::Resource::Param.
361
+ new(:name => 'message', :value => 'howdy')
362
+ @collector.add_override(:parameters => [param], :scope => @scope)
523
363
 
524
- @collector.evaluate.should == [@resource]
525
- end
364
+ got = @collector.evaluate
365
+ got.first[:message].should == param.value
366
+ end
526
367
 
527
- it "should not join parameters when querying ActiveRecord with a tag exported query" do
528
- @collector.equery = "puppet_tags.name = test"
529
- Puppet::Rails::Resource.stubs(:find).with { |*arguments|
530
- options = arguments[1]
531
- options[:joins] == {:param_values => :param_name}
532
- }.returns([@resource])
368
+ it "should store converted resources in the compile's resource list" do
369
+ host = Puppet::Rails::Host.create!(:name => 'one.local')
370
+ Puppet::Rails::Resource.
371
+ create!(:host => host,
372
+ :restype => 'notify', :title => 'whammo',
373
+ :exported => true)
374
+
375
+ @compiler.expects(:add_resource).with do |scope, resource|
376
+ scope.should be_an_instance_of Puppet::Parser::Scope
377
+ resource.type.should == 'Notify'
378
+ resource.title.should == 'whammo'
379
+ true
380
+ end
381
+
382
+ @collector.evaluate
383
+ end
533
384
 
534
- @collector.evaluate.should be_false
535
- end
385
+ # This way one host doesn't store another host's resources as exported.
386
+ it "should mark resources collected from the database as not exported" do
387
+ host = Puppet::Rails::Host.create!(:name => 'one.local')
388
+ Puppet::Rails::Resource.
389
+ create!(:host => host,
390
+ :restype => 'notify', :title => 'whammo',
391
+ :exported => true)
392
+
393
+ got = @collector.evaluate
394
+ got.length.should == 1
395
+ got.first.type.should == "Notify"
396
+ got.first.title.should == "whammo"
397
+ got.first.should_not be_exported
398
+ end
536
399
 
537
- it "should only search for exported resources with the matching type" do
538
- Puppet::Rails::Resource.stubs(:find).with { |*arguments|
539
- options = arguments[1]
540
- options[:conditions][0].include?("(exported=? AND restype=?)") and options[:conditions][1] == true and options[:conditions][2] == "Mytype"
541
- }.returns([@resource])
400
+ it "should fail if an equivalent resource already exists in the compile" do
401
+ host = Puppet::Rails::Host.create!(:name => 'one.local')
402
+ Puppet::Rails::Resource.
403
+ create!(:host => host,
404
+ :restype => 'notify', :title => 'whammo',
405
+ :exported => true)
542
406
 
543
- @collector.evaluate.should == [@resource]
544
- end
407
+ local = Puppet::Parser::Resource.new('notify', 'whammo', :scope => @scope)
408
+ @compiler.add_resource(@scope, local)
545
409
 
546
- it "should include the export query if one is provided" do
547
- @collector.equery = "test = true"
548
- Puppet::Rails::Resource.stubs(:find).with { |*arguments|
549
- options = arguments[1]
550
- options[:conditions][0].include?("test = true")
551
- }.returns([@resource])
410
+ expect { @collector.evaluate }.
411
+ to raise_error Puppet::ParseError, /cannot override local resource/
412
+ end
552
413
 
553
- @collector.evaluate.should == [@resource]
414
+ it "should ignore exported resources that match already-collected resources" do
415
+ host = Puppet::Rails::Host.create!(:name => 'one.local')
416
+ # One that we already collected...
417
+ db = Puppet::Rails::Resource.
418
+ create!(:host => host,
419
+ :restype => 'notify', :title => 'whammo',
420
+ :exported => true)
421
+ # ...and one we didn't.
422
+ Puppet::Rails::Resource.
423
+ create!(:host => host,
424
+ :restype => 'notify', :title => 'boingy-boingy',
425
+ :exported => true)
426
+
427
+ local = Puppet::Parser::Resource.new('notify', 'whammo',
428
+ :scope => @scope,
429
+ :collector_id => db.id)
430
+ @compiler.add_resource(@scope, local)
431
+
432
+ got = nil
433
+ expect { got = @collector.evaluate }.not_to raise_error(Puppet::ParseError)
434
+ got.length.should == 1
435
+ got.first.type.should == "Notify"
436
+ got.first.title.should == "boingy-boingy"
437
+ end
554
438
  end
555
439
  end