# Inspec test for recipe irrigate-php::qa_vapi

# The Inspec reference, with examples and extensive documentation, can be
# found at http://inspec.io/docs/reference/resources/

control 'qa_vapi' do
  attribute_file = '/tmp/kitchen/node_attributes.json'
  if file(attribute_file).exist?
    node = json(attribute_file).params

    case node['automatic']['platform_family']
    when 'rhel'
      if node['automatic']['platform_version'].to_s.start_with?('7')
        packages = %w(
          php56-php-pecl-apcu
          php56-php-pecl-yaml
        )

        packages.each do |name|
          describe package name do
            it { should be_installed }
          end
        end

      end
    end

  else
    puts "File #{attribute_file} does not exist, skiping attribute-depending checks"
  end
end
