mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 14:47:19 -04:00
#4324 streamline behaviour of Timestamp.== and Timestamp.eql?
Fixes #7002
This commit is contained in:
parent
822d7fe506
commit
11d34204f5
2 changed files with 10 additions and 0 deletions
|
@ -13,6 +13,10 @@ module LogStash
|
|||
self.time <=> other.time
|
||||
end
|
||||
|
||||
def eql?(other)
|
||||
self.== other
|
||||
end
|
||||
|
||||
# TODO (colin) implement in Java
|
||||
def +(other)
|
||||
self.time + other
|
||||
|
|
|
@ -20,6 +20,12 @@ describe LogStash::Timestamp do
|
|||
expect(t.time.to_i).to eq(now.to_i)
|
||||
end
|
||||
|
||||
it "should have consistent behaviour across == and .eql?" do
|
||||
its_xmas = Time.utc(2015, 12, 25, 0, 0, 0)
|
||||
expect(LogStash::Timestamp.new(its_xmas)).to eql(LogStash::Timestamp.new(its_xmas))
|
||||
expect(LogStash::Timestamp.new(its_xmas)).to be ==(LogStash::Timestamp.new(its_xmas))
|
||||
end
|
||||
|
||||
it "should raise exception on invalid format" do
|
||||
expect{LogStash::Timestamp.new("foobar")}.to raise_error
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue