Construct fixtures for reference validation integration tests

This commit is contained in:
Kevin Paulisse 2016-12-20 11:34:23 -06:00
Родитель 6e3eb0b7c6
Коммит 0be32abe2f
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 66DA91D838188671
5 изменённых файлов: 99 добавлений и 0 удалений

Просмотреть файл

@ -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