# Copyright:: 2011-Present, Datadog
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Encoding: utf-8

require 'spec_helper'

PROCESS_CONFIG = File.join(@agent_config_dir, 'conf.d/process.d/conf.yaml')

describe service(@agent_service_name) do
  it { should be_running }
end

describe file(PROCESS_CONFIG) do
  it { should be_a_file }

  it 'is valid yaml matching input values' do
    generated = YAML.load_file(PROCESS_CONFIG)

    expected = {
      'instances' => [
        {
          'name' => 'pidname',
          'exact_match' => false,
          'ignore_denied_access' => true,
          'tags' => ['env:test', 'appname:somename'],
          'search_string' => ['somepid', 'pidname']
        }
      ],
      'logs' => nil,
      'init_config' => nil
    }

    expect(generated.to_json).to be_json_eql expected.to_json
  end
end
