<commit_before>require 'serverspec'

details = {}

if RUBY_PLATFORM =~ /(win|mswin|mingw)/i
  set :backend, :cmd
  set :os, :family => 'windows'
  details = {
    check_executable: false,
    check_owner:      false,
    config:           "c:\\Program Files (x86)\\Instrumental Tools\\etc\\instrumental.yml",
    executable:       "c:\\Program Files (x86)\\Instrumental Tools\\instrument_server.bat",
    has_pid:          false,
    service_name:     "Instrument Server"
  }
else
  set :backend, :exec
  details = {
    check_executable: true,
    check_owner:      true,
    config:           "/etc/instrumental.yml",
    executable:       "/opt/instrumental-tools/instrument_server",
    has_pid:          true,
    pid_path:         "/opt/instrumental-tools/instrument_server.pid",
    owner:            "nobody",
    service_name:     "instrument_server"
  }
end


describe file(details[:executable]) do
  it { should be_file }
  if details[:check_executable]
    it { should be_executable }
  end
end

describe service(details[:service_name]) do
  it { should be_enabled }
  it { should be_running }
end

if details[:has_pid]
  describe file(details[:pid_path]) do
    it { should be_file }
    if details[:check_owner]
      it { should be_owned_by(details[:owner]) }
    end
  end
end

describe file(details[:config]) do
  it { should be_file }
  if details[:check_owner]
    it { should be_owned_by(details[:owner]) }<commit_msg>remove file existence tests, not necessary w/ service running test<commit_after>require 'serverspec'

details = {}

if RUBY_PLATFORM =~ /(win|mswin|mingw)/i
  set :backend, :cmd
  set :os, :family => 'windows'
  details = {
    check_owner:      false,
    config:           "c:\\Program Files (x86)\\Instrumental Tools\\etc\\instrumental.yml",
    has_pid:          false,
    service_name:     "Instrument Server"
  }
else
  set :backend, :exec
  details = {
    check_owner:      true,
    config:           "/etc/instrumental.yml",
    has_pid:          true,
    pid_path:         "/opt/instrumental-tools/instrument_server.pid",
    owner:            "nobody",
    service_name:     "instrument_server"
  }
end

describe service(details[:service_name]) do
  it { should be_enabled }
  it { should be_running }
end

if details[:has_pid]
  describe file(details[:pid_path]) do
    it { should be_file }
    if details[:check_owner]
      it { should be_owned_by(details[:owner]) }
    end
  end
end

describe file(details[:config]) do
  it { should be_file }
  if details[:check_owner]
    it { should be_owned_by(details[:owner]) }
{'fraction_non_alphanumeric': 0.11732711732711733, 'fraction_numerical': 0.002331002331002331, 'mean_word_length': 2.854790419161677, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6815282', 'n_tokens_mistral': 862, 'n_tokens_neox': 848, 'n_words': 195}