<commit_before>describe Fluent::DdOutput do
  let(:time) {
    Time.parse('2014-02-08 04:14:15 UTC').to_i
  }

  it 'should receive an API key' do
    Dogapi::Client.should_receive(:new).with("test_dd_api_key", nil, "test_host")
    run_driver {|d, dog| }
  end

  it 'should be called emit_points' do
    run_driver do |d, dog|
      dog.should_receive(:emit_points).with(
        "some.metric.name",
        [[Time.parse("2014-02-08 04:14:15 UTC"), 50.0],
         [Time.parse("2014-02-08 04:14:15 UTC"), 100.0]],
        {"tags"=>["test.default"]}
      )

      d.emit({"metric" => "some.metric.name", "value" => 50.0}, time)
      d.emit({"metric" => "some.metric.name", "value" => 100.0}, time)
    end
  end

  it 'should be called emit_points for each tag' do
    run_driver do |d, dog|
      dog.should_receive(:emit_points).with(
        "some.metric.name",
        [[Time.parse("2014-02-08 04:14:15 UTC"), 50.0],
         [Time.parse("2014-02-08 04:14:15 UTC"), 100.0]],
        {"tags"=>["test.1"]}
      )

      dog.should_receive(:emit_points).with(
        "some.metric.name",
        [[Time.parse("2014-02-08 04:14:15 UTC"), 150.0],
         [Time.parse("2014-02-08 04:14:15 UTC"), 200.0]],
        {"tags"=>["test.2"]}
      )

      dog.should_receive(:emit_points).with(
        "some.metric.name",
        [[Time.parse("2014-02-08 04:14:15 UTC"), 250.0],
         [Time.parse("2014-02-08 04:14:15 UTC"), 300.0]],
        {"tags"=>["test.3"]}
      )

      d.tag = 'test.1'
      d.emit({"metric" => "some.metric.name", "value" => 50.0}, time)
      d.emit({"metric" => "some.metric.name", "value" => 100.0}, time)

      d.tag = 'test.2'
      d.emit({"metric" => "some.metric.name", "value" => 150.0}, time)
      d.emit({"metric" => "some.metric.name", "value" => 200.0}, time)

      d.tag = 'test.3'
      d.emit({"metric" => "some.metric.name", "value" => 250.0}, time)
      d.emit({"metric" => "some.metric.name", "value" => 300.0}, time)
    end
  end

  it 'should be called emit_points for each host' do
    run_driver do |d, dog|
      dog.should_receive(:emit_points).with(<commit_msg>Add spec<commit_after>describe Fluent::DdOutput do
  let(:time) {
    Time.parse('2014-02-08 04:14:15 UTC').to_i
  }

  it 'should receive an API key' do
    Dogapi::Client.should_receive(:new).with("test_dd_api_key", nil, "test_host")
    run_driver {|d, dog| }
  end

  it 'should be called emit_points' do
    run_driver do |d, dog|
      dog.should_receive(:emit_points).with(
        "some.metric.name",
        [[Time.parse("2014-02-08 04:14:15 UTC"), 50.0],
         [Time.parse("2014-02-08 04:14:15 UTC"), 100.0]],
        {"tags"=>["test.default"]}
      )

      d.emit({"metric" => "some.metric.name", "value" => 50.0}, time)
      d.emit({"metric" => "some.metric.name", "value" => 100.0}, time)
    end
  end

  it 'should be called emit_points for each tag' do
    run_driver do |d, dog|
      dog.should_receive(:emit_points).with(
        "some.metric.name",
        [[Time.parse("2014-02-08 04:14:15 UTC"), 50.0],
         [Time.parse("2014-02-08 04:14:15 UTC"), 100.0]],
        {"tags"=>["test.1"]}
      )

      dog.should_receive(:emit_points).with(
        "some.metric.name",
        [[Time.parse("2014-02-08 04:14:15 UTC"), 150.0],
         [Time.parse("2014-02-08 04:14:15 UTC"), 200.0]],
        {"tags"=>["test.2"]}
      )

      dog.should_receive(:emit_points).with(
        "some.metric.name",
        [[Time.parse("2014-02-08 04:14:15 UTC"), 250.0],
         [Time.parse("2014-02-08 04:14:15 UTC"), 300.0]],
        {"tags"=>["test.3"]}
      )

      d.tag = 'test.1'
      d.emit({"metric" => "some.metric.name", "value" => 50.0}, time)
      d.emit({"metric" => "some.metric.name", "value" => 100.0}, time)

      d.tag = 'test.2'
      d.emit({"metric" => "some.metric.name", "value" => 150.0}, time)
      d.emit({"metric" => "some.metric.name", "value" => 200.0}, time)

      d.tag = 'test.3'
      d.emit({"metric" => "some.metric.name", "value" => 250.0}, time)
      d.emit({"metric" => "some.metric.name", "value" => 300.0}, time)
    end
  end

  it 'should be called emit_points for each tag (tag is included in the record)' do
    run_driver do |d, dog|
      dog.should_receive(:emit_points).with(
        "some.metric.name",
        [[Time.parse("2014-02-08 04:14:15 UTC"), 50.0],
         [Time.parse("2014-02-08 04:14:15 UTC"), 100.0]],
        {"tags"=>["test.11"]}
      )

      dog.should_receive(:emit_points).with(
        "some.metric.name",
        [[Time.parse("2014-02-08 04:14:15 UTC"), 150.0],
         [Time.parse("2014-02-08 04:14:15 UTC"), 200.0]],
        {"tags"=>["test.21"]}
      )

      dog.should_receive(:emit_points).with(
        "some.metric.name",
        [[Time.parse("2014-02-08 04:14:15 UTC"), 250.0],
         [Time.parse("2014-02-08 04:14:15 UTC"), 300.0]],
        {"tags"=>["test.31"]}
      )

      d.emit({"metric" => "some.metric.name", "value" => 50.0,  "tag" => "test.11"}, time)
      d.emit({"metric" => "some.metric.name", "value" => 100.0, "tag" => "test.11"}, time)

      d.emit({"metric" => "some.metric.name", "value" => 150.0, "tag" => "test.21"}, time)
      d.emit({"metric" => "some.metric.name", "value" => 200.0, "tag" => "test.21"}, time)

      d.emit({"metric" => "some.metric.name", "value" => 250.0, "tag" => "test.31"}, time)
      d.emit({"metric" => "some.metric.name", "value" => 300.0, "tag" => "test.31"}, time)
    end
  end

  it 'should be called emit_points for each host' do
    run_driver do |d, dog|
      dog.should_receive(:emit_points).with(
{'fraction_non_alphanumeric': 0.22086987649901557, 'fraction_numerical': 0.09522104886343297, 'mean_word_length': 2.600515463917526, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 64, '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': '4469830', 'n_tokens_mistral': 2478, 'n_tokens_neox': 2086, 'n_words': 400}