Construct fixtures for reference validation integration tests
This commit is contained in:
Родитель
6e3eb0b7c6
Коммит
0be32abe2f
|
@ -0,0 +1,10 @@
|
|||
---
|
||||
:backends:
|
||||
- yaml
|
||||
:yaml:
|
||||
:datadir: /var/lib/puppet/environments/%{::environment}/hieradata
|
||||
:hierarchy:
|
||||
- roles/%{::reference_validation_role}
|
||||
- common
|
||||
:merge_behavior: deeper
|
||||
:logger: console
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
classes:
|
||||
- test
|
|
@ -0,0 +1,3 @@
|
|||
node default {
|
||||
hiera_include('classes')
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
class test {
|
||||
|
||||
# Test resource
|
||||
file { '/tmp/test-main':
|
||||
content => 'it works',
|
||||
}
|
||||
|
||||
# Targets for require, before, subscribe, notify
|
||||
exec { 'target 1':
|
||||
command => '/bin/true',
|
||||
}
|
||||
|
||||
exec { 'target 2':
|
||||
command => '/bin/true',
|
||||
}
|
||||
|
||||
exec { 'target 3':
|
||||
command => '/bin/true',
|
||||
}
|
||||
|
||||
exec { 'target 4':
|
||||
command => '/bin/true',
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require_relative 'integration_helper'
|
||||
require 'json'
|
||||
|
||||
module OctocatalogDiff
|
||||
class Spec
|
||||
def self.reference_validation_catalog(role, validations)
|
||||
argv = ['--catalog-only', '-n', 'rspec-node.github.net', '--to-fact-override', "reference_validation_role=#{role}"]
|
||||
validations.each { |v| argv.concat ['--validate-references', v] }
|
||||
OctocatalogDiff::Integration.integration(
|
||||
hiera_config: 'hiera.yaml',
|
||||
spec_fact_file: 'facts.yaml',
|
||||
spec_repo: 'reference-validation',
|
||||
argv: argv
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'validation of sample catalog' do
|
||||
before(:all) do
|
||||
@result = OctocatalogDiff::Spec.reference_validation_catalog('valid', [])
|
||||
end
|
||||
|
||||
it 'should return the valid catalog' do
|
||||
expect(@result.exitcode).to eq(2)
|
||||
end
|
||||
|
||||
it 'should not raise any exceptions' do
|
||||
expect(@result.exception).to be_nil, OctocatalogDiff::Integration.format_exception(@result)
|
||||
end
|
||||
|
||||
it 'should contain representative resources' do
|
||||
json_obj = JSON.parse(@result.output)
|
||||
resources = json_obj['resources'] || json_obj['data']['resources']
|
||||
expect(resources).to be_a_kind_of(Array)
|
||||
expect(resources.select { |x| x['type'] == 'File' && x['title'] == '/tmp/test-main' }.size).not_to eq(0)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'validation of references' do
|
||||
context 'with valid catalog' do
|
||||
it 'should not throw error' do
|
||||
end
|
||||
end
|
||||
|
||||
context 'with broken require' do
|
||||
end
|
||||
|
||||
context 'with broken before' do
|
||||
end
|
||||
|
||||
context 'with broken notify' do
|
||||
end
|
||||
|
||||
context 'with broken subscribe' do
|
||||
end
|
||||
end
|
Загрузка…
Ссылка в новой задаче