|
283 | 283 | puppetdb_server_url_timeout: 120 |
284 | 284 | } |
285 | 285 | end |
| 286 | + |
286 | 287 | context 'with relative path' do |
287 | 288 | it 'should install the hiera configuration file' do |
288 | 289 | options = default_options.merge(hiera_config: 'config/hiera.yaml') |
|
309 | 310 | end |
310 | 311 | end |
311 | 312 |
|
| 313 | + context 'with relevant path and an alternate environment' do |
| 314 | + let(:alternate_opts) do |
| 315 | + { |
| 316 | + basedir: OctocatalogDiff::Spec.fixture_path('repos/preserve-environments'), |
| 317 | + hiera_config: 'hiera.yaml', |
| 318 | + preserve_environments: true, |
| 319 | + environment: 'one' |
| 320 | + } |
| 321 | + end |
| 322 | + |
| 323 | + it 'should install the hiera configuration file' do |
| 324 | + options = default_options.merge(alternate_opts) |
| 325 | + logger, _logger_str = OctocatalogDiff::Spec.setup_logger |
| 326 | + testobj = OctocatalogDiff::CatalogUtil::BuildDir.new(options, logger) |
| 327 | + hiera_yaml = File.join(testobj.tempdir, 'hiera.yaml') |
| 328 | + expect(File.file?(hiera_yaml)).to eq(true) |
| 329 | + hiera_cfg = YAML.load_file(hiera_yaml) |
| 330 | + expect(hiera_cfg[:backends]).to eq(['yaml']) |
| 331 | + expect(hiera_cfg[:yaml]).to eq(datadir: '/var/lib/puppet/environments/one/hieradata') |
| 332 | + end |
| 333 | + |
| 334 | + it 'should handle hiera_path_strip with respect to the environment' do |
| 335 | + options = default_options.merge(alternate_opts.merge(hiera_path_strip: '/var/lib/puppet')) |
| 336 | + logger, logger_str = OctocatalogDiff::Spec.setup_logger |
| 337 | + testobj = OctocatalogDiff::CatalogUtil::BuildDir.new(options, logger) |
| 338 | + hiera_yaml = File.join(testobj.tempdir, 'hiera.yaml') |
| 339 | + expect(File.file?(hiera_yaml)).to eq(true) |
| 340 | + hiera_cfg = YAML.load_file(hiera_yaml) |
| 341 | + expect(hiera_cfg[:backends]).to eq(['yaml']) |
| 342 | + expect(hiera_cfg[:yaml]).to eq(datadir: File.join(testobj.tempdir, 'environments', 'one', 'hieradata')) |
| 343 | + expect(logger_str.string).not_to match(/Hiera datadir for yaml doesn't seem to exist/) |
| 344 | + end |
| 345 | + end |
| 346 | + |
| 347 | + context 'with relevant path including an alternate environment' do |
| 348 | + let(:alternate_opts) do |
| 349 | + { |
| 350 | + basedir: OctocatalogDiff::Spec.fixture_path('repos/preserve-environments'), |
| 351 | + hiera_config: 'environments/one/hiera.yaml', |
| 352 | + preserve_environments: true, |
| 353 | + environment: 'one' |
| 354 | + } |
| 355 | + end |
| 356 | + |
| 357 | + it 'should install the hiera configuration file' do |
| 358 | + options = default_options.merge(alternate_opts) |
| 359 | + logger, _logger_str = OctocatalogDiff::Spec.setup_logger |
| 360 | + testobj = OctocatalogDiff::CatalogUtil::BuildDir.new(options, logger) |
| 361 | + hiera_yaml = File.join(testobj.tempdir, 'hiera.yaml') |
| 362 | + expect(File.file?(hiera_yaml)).to eq(true) |
| 363 | + hiera_cfg = YAML.load_file(hiera_yaml) |
| 364 | + expect(hiera_cfg[:backends]).to eq(['yaml']) |
| 365 | + expect(hiera_cfg[:yaml]).to eq(datadir: '/var/lib/puppet/environments/one/hieradata') |
| 366 | + end |
| 367 | + |
| 368 | + it 'should handle hiera_path_strip with respect to the environment' do |
| 369 | + options = default_options.merge(alternate_opts.merge(hiera_path_strip: '/var/lib/puppet')) |
| 370 | + logger, logger_str = OctocatalogDiff::Spec.setup_logger |
| 371 | + testobj = OctocatalogDiff::CatalogUtil::BuildDir.new(options, logger) |
| 372 | + hiera_yaml = File.join(testobj.tempdir, 'hiera.yaml') |
| 373 | + expect(File.file?(hiera_yaml)).to eq(true) |
| 374 | + hiera_cfg = YAML.load_file(hiera_yaml) |
| 375 | + expect(hiera_cfg[:backends]).to eq(['yaml']) |
| 376 | + expect(hiera_cfg[:yaml]).to eq(datadir: File.join(testobj.tempdir, 'environments', 'one', 'hieradata')) |
| 377 | + expect(logger_str.string).not_to match(/Hiera datadir for yaml doesn't seem to exist/) |
| 378 | + end |
| 379 | + end |
| 380 | + |
312 | 381 | context 'with absolute path' do |
313 | 382 | it 'should install the hiera configuration file' do |
314 | 383 | options = default_options.merge(hiera_config: OctocatalogDiff::Spec.fixture_path('repos/default/config/hiera.yaml')) |
|
0 commit comments