Sha256: d65c1a98c96e13d3c2906d4f0a73463d7079ab73e4599b9f33c5ff2cf5879764

Contents?: true

Size: 1.95 KB

Versions: 2

Compression:

Stored size: 1.95 KB

Contents

# encoding: utf-8
# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.

require File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','test_helper'))

class NewRelic::Agent::Transaction
  class DeveloperModeSampleBufferTest < Test::Unit::TestCase
    def setup
      @buffer = DeveloperModeSampleBuffer.new
    end

    def test_store_sample_for_developer_mode_in_dev_mode
      with_config(:developer_mode => true) do
        sample = stub
        @buffer.store(sample)
        assert_equal([sample], @buffer.samples)
      end
    end

    def test_store_sample_for_developer_mode_not_in_dev_mode
      with_config(:developer_mode => false) do
        @buffer.store(stub)
        assert(@buffer.samples.empty?)
      end
    end

    def test_stores_up_to_truncate_max
      sample = stub
      @buffer.max_samples.times { @buffer.store(sample) }

      assert_equal(Array.new(@buffer.max_samples, sample), @buffer.samples)
    end

    def test_stores_and_truncates
      sample = stub
      (@buffer.max_samples * 2).times { @buffer.store(sample) }

      assert_equal(Array.new(@buffer.max_samples, sample), @buffer.samples)
    end

    def test_visit_segment_takes_backtraces_in_dev_mode
      with_config(:developer_mode => true) do
        segment = {}
        @buffer.visit_segment(segment)
        assert segment[:backtrace].any? {|trace_line| trace_line.include?(__FILE__)}
      end
    end

    def test_visit_segment_takes_backtraces_not_in_dev_mode
      with_config(:developer_mode => false) do
        segment = {}
        @buffer.visit_segment(segment)
        assert_nil segment[:backtrace]
      end
    end

    def test_visit_segment_safe_against_nils
      with_config(:developer_mode => true) do
        @buffer.visit_segment(nil)
      end
    end

    def test_doesnt_store_previous
      @buffer.store_previous([stub])
      assert @buffer.samples.empty?
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
newrelic_rpm-3.6.8.168 test/new_relic/agent/transaction/developer_mode_sample_buffer_test.rb
newrelic_rpm-3.6.8.164 test/new_relic/agent/transaction/developer_mode_sample_buffer_test.rb