elastic / logstash-devutils

An assortment of tooling/libraries to make Logstash core and plugin development and releasing a bit easier.
Apache License 2.0
18 stars 27 forks source link

Move `be_a_logstash_timestamp_equivalent_to` into this gem to be reused #98

Closed andsel closed 3 years ago

andsel commented 3 years ago

With the PR on the integration-jdbc and on filter-date the same utility matcher was copied and pasted:

  RSpec::Matchers.define :be_a_logstash_timestamp_equivalent_to do |expected|
    expected = LogStash::Timestamp.new(expected) unless expected.kind_of?(LogStash::Timestamp)
    description { "be a LogStash::Timestamp equivalent to #{expected}" }

    match do |actual|
      actual.kind_of?(LogStash::Timestamp) && actual == expected
    end
  end

This matcher is used in timestamp expectations to avoid string equality and be portable across different versions of Logstash. With Logstash PR https://github.com/elastic/logstash/pull/12797 was introduced nanosecond precision and this made fails some plugins test that was based on string compare on timestamps.

Tasks:

andsel commented 3 years ago

All points done