<commit_before>require 'bipbip'
require 'bipbip/plugin/command'

describe Bipbip::Plugin::Command do
  let(:plugin1) { Bipbip::Plugin::Command.new('command', {'command' => 'command', 'mode' => 'simple'}, 10) }
  let(:plugin2) { Bipbip::Plugin::Command.new('command', {'command' => 'command', 'mode' => 'advanced'}, 10) }

  it 'should collect data for simple mode' do

    plugin1.stub(:exec_command).and_return(
<<DATA
{
  "common_ok": true,
  "router_ok": false,
  "config_ok": true,
  "replica_ok": true,
  "mms_ok": true,
  "cluster_ok": false
}
DATA
    )

    data = plugin1.monitor

    data['common_ok'].should eq(1)
    data['router_ok'].should eq(0)
    data['cluster_ok'].should eq(0)
  end

  it 'should collect data for advanced mode' do

    plugin2.stub(:exec_command).and_return(
        <<DATA
{
  "common_ok": {"value": false, "type": "gauge", "unit": "Boolean"},
  "report_ok": {"value": "true", "type": "gauge", "unit": "Boolean"},
  "router_count":  {"value": 4, "type": "gauge", "unit": "Members"},
  "puppet_runtime":  {"value": 123, "type": "gauge", "unit": "Seconds"},
  "run_errors":  {"value": 199, "type": "counter", "unit": "Integer"}
}
DATA
    )

    data = plugin2.monitor

    data['common_ok'].should eq(0)
    data['report_ok'].should eq(1)
    data['router_count'].should eq(4)<commit_msg>Updated specs<commit_after>require 'bipbip'
require 'bipbip/plugin/command'

describe Bipbip::Plugin::Command do
  let(:plugin1) { Bipbip::Plugin::Command.new('command', {'command' => 'command'}, 10) }
  let(:plugin2) { Bipbip::Plugin::Command.new('command', {'command' => 'command'}, 10) }

  it 'should collect data for simple mode' do

    plugin1.stub(:exec_command).and_return(
<<DATA
{
  "common_ok": true,
  "router_ok": false,
  "config_ok": true,
  "replica_ok": true,
  "mms_ok": true,
  "cluster_ok": false
}
DATA
    )

    plugin1.metrics_schema
    data = plugin1.monitor

    data['common_ok'].should eq(1)
    data['router_ok'].should eq(0)
    data['cluster_ok'].should eq(0)
  end

  it 'should collect data for advanced mode' do

    plugin2.stub(:exec_command).and_return(
        <<DATA
{
  "common_ok": {"value": false, "type": "gauge", "unit": "Boolean"},
  "report_ok": {"value": "true", "type": "gauge", "unit": "Boolean"},
  "router_count":  {"value": 4, "type": "gauge", "unit": "Members"},
  "puppet_runtime":  {"value": 123, "type": "gauge", "unit": "Seconds"},
  "run_errors":  {"value": 199, "type": "counter", "unit": "Integer"}
}
DATA
    )

    plugin2.metrics_schema
    data = plugin2.monitor

    data['common_ok'].should eq(0)
    data['report_ok'].should eq(1)
    data['router_count'].should eq(4)
{'fraction_non_alphanumeric': 0.20285499624342598, 'fraction_numerical': 0.018031555221637866, 'mean_word_length': 4.50206611570248, 'pattern_counts': {'":': 52, '<': 11, '<?xml version=': 0, '>': 9, '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': '3811865', 'n_tokens_mistral': 998, 'n_tokens_neox': 952, 'n_words': 212}