Sha256: 32514deb5268f8d18d3b796eaaf2954ec3eb57c91ab7c6dcbf2f17d5d1f8229a

Contents?: true

Size: 975 Bytes

Versions: 12

Compression:

Stored size: 975 Bytes

Contents

# encoding: utf-8

require "spec_helper"
require "logstash/timestamp"

describe LogStash::Timestamp do
  context "constructors" do
    it "should work" do
      t = LogStash::Timestamp.new
      expect(t.time.to_i).to be_within(1).of Time.now.to_i

      t = LogStash::Timestamp.now
      expect(t.time.to_i).to be_within(1).of Time.now.to_i

      now = Time.now.utc
      t = LogStash::Timestamp.new(now)
      expect(t.time).to eq(now)

      t = LogStash::Timestamp.at(now.to_i)
      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

  end

end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
logstash-core-5.6.1-java spec/logstash/timestamp_spec.rb
logstash-core-5.5.3-java spec/logstash/timestamp_spec.rb
logstash-core-5.6.0-java spec/logstash/timestamp_spec.rb
logstash-core-5.5.2-java spec/logstash/timestamp_spec.rb
logstash-core-5.5.1-java spec/logstash/timestamp_spec.rb
logstash-filter-cache-redis-0.3.1 vendor/bundle/jruby/1.9/gems/logstash-core-5.5.1.snapshot1-java/spec/logstash/timestamp_spec.rb
logstash-filter-cache-redis-0.3.0 vendor/bundle/jruby/1.9/gems/logstash-core-5.5.1.snapshot1-java/spec/logstash/timestamp_spec.rb
logstash-core-5.5.1.snapshot1-java spec/logstash/timestamp_spec.rb
logstash-filter-cache-redis-0.2.0 vendor/bundle/jruby/1.9/gems/logstash-core-5.5.0-java/spec/logstash/timestamp_spec.rb
logstash-core-5.5.0-java spec/logstash/timestamp_spec.rb
logstash-core-6.0.0.alpha2-java spec/logstash/timestamp_spec.rb
logstash-core-6.0.0.alpha1-java spec/logstash/timestamp_spec.rb