Sha256: 8a5c6a365ac449588f59a27e060369697a3ba3a4c28a53d7a7573e88ba14a87d

Contents?: true

Size: 938 Bytes

Versions: 3

Compression:

Stored size: 938 Bytes

Contents

class TestReceived

  def initialize(events, file)
    @events = events
    @file = file
  end

  def data
    @data ||= YAML.load_file(@file)
  end

  def compare!

    @events.each do |e|
      data["events"].each do |d|
        next unless d[:service] == e[:service]
        next if d[:result] == e[:state]
        next if d[:time] && d[:time] != e[:time]
        raise "Recieved state: #{e[:state].inspect}, data state: #{d[:result].inspect}. \n Data: #{d.inspect} \n Event: #{e.inspect}"
      end
    end

    from_data = data["events"].select {|x| x[:miss_count] != true }.count
    from_events = @events.count

    raise "Not all events recieved: from data: #{from_data} and from server: #{from_events}" unless 3 * from_data == from_events # see config.yml (3 copy of sample plugin run)

    puts "Recieved events:"
    puts "#{@events.inspect}"
    puts "Sample data:"
    puts "#{data.inspect}"

    puts "All done!"
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
kurchatov-0.2.4 tests/testreceived.rb
kurchatov-0.2.3 tests/testreceived.rb
kurchatov-0.2.2 tests/testreceived.rb