Skip to content
This repository has been archived by the owner on May 2, 2021. It is now read-only.

Commit

Permalink
Merge pull request elastic#633 from wiibaa/spec-output-file
Browse files Browse the repository at this point in the history
Correct test case spec/output/file.rb
  • Loading branch information
nickethier committed Sep 19, 2013
2 parents 45c7896 + edded01 commit 42f11e3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
14 changes: 3 additions & 11 deletions lib/logstash/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,10 @@ def initialize(data={})
data["@version"] = "1" if !@data.include?("@version")
end # def initialize

# Add class methods on inclusion.
public
def self.included(klass)
klass.extend(ClassMethods)
end # def included

module ClassMethods
public
def from_json(json)
return self.new(JSON.parse(json))
end # def from_json
end
def self.from_json(json)
return self.new(JSON.parse(json))
end # def from_json

public
def cancel
Expand Down
14 changes: 12 additions & 2 deletions spec/outputs/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
# Now check all events for order and correctness.
File.foreach(tmp_file) do |line|
event = LogStash::Event.from_json(line)
insist {event.message} == "hello world"
insist {event["message"]} == "hello world"
insist {event["sequence"]} == line_num
line_num += 1
end
Expand Down Expand Up @@ -62,7 +62,17 @@
# Now check all events for order and correctness.
Zlib::GzipReader.new(File.open(tmp_file)).each_line do |line|
event = LogStash::Event.from_json(line)
insist {event.message} == "hello world"
insist {event["message"]} == "hello world"
insist {event["sequence"]} == line_num
line_num += 1
end
insist {line_num} == event_count

#LOGSTASH-997 confirm usage of zcat command on file
line_num = 0
`zcat #{tmp_file.path()}`.split("\n").each do |line|
event = LogStash::Event.from_json(line)
insist {event["message"]} == "hello world"
insist {event["sequence"]} == line_num
line_num += 1
end
Expand Down

0 comments on commit 42f11e3

Please sign in to comment.