mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 06:37:19 -04:00
Update to use 'subject' so tests don't conflict with eachother
This commit is contained in:
parent
91a4a5108a
commit
341ab0f05e
1 changed files with 20 additions and 16 deletions
|
@ -10,13 +10,15 @@ describe LogStash::Inputs::IMAP do
|
|||
msg_text = "foo\nbar\nbaz"
|
||||
msg_html = "<p>a paragraph</p>\n\n"
|
||||
|
||||
msg = Mail.new do
|
||||
from "me@example.com"
|
||||
to "you@example.com"
|
||||
subject "logstash imap input test"
|
||||
date msg_time
|
||||
body msg_text
|
||||
add_file :filename => "some.html", :content => msg_html
|
||||
subject do
|
||||
Mail.new do
|
||||
from "me@example.com"
|
||||
to "you@example.com"
|
||||
subject "logstash imap input test"
|
||||
date msg_time
|
||||
body msg_text
|
||||
add_file :filename => "some.html", :content => msg_html
|
||||
end
|
||||
end
|
||||
|
||||
context "with both text and html parts" do
|
||||
|
@ -27,7 +29,7 @@ describe LogStash::Inputs::IMAP do
|
|||
|
||||
input = LogStash::Inputs::IMAP.new config
|
||||
input.register
|
||||
event = input.parse_mail(msg)
|
||||
event = input.parse_mail(subject)
|
||||
insist { event["message"] } == msg_text
|
||||
end
|
||||
end
|
||||
|
@ -40,7 +42,7 @@ describe LogStash::Inputs::IMAP do
|
|||
|
||||
input = LogStash::Inputs::IMAP.new config
|
||||
input.register
|
||||
event = input.parse_mail(msg)
|
||||
event = input.parse_mail(subject)
|
||||
insist { event["message"] } == msg_html
|
||||
end
|
||||
end
|
||||
|
@ -48,40 +50,42 @@ describe LogStash::Inputs::IMAP do
|
|||
|
||||
context "when subject is in RFC 2047 encoded-word format" do
|
||||
it "should be decoded" do
|
||||
msg.subject = "=?iso-8859-1?Q?foo_:_bar?="
|
||||
subject.subject = "=?iso-8859-1?Q?foo_:_bar?="
|
||||
config = {"type" => "imap", "host" => "localhost",
|
||||
"user" => "#{user}", "password" => "#{password}"}
|
||||
|
||||
input = LogStash::Inputs::IMAP.new config
|
||||
input.register
|
||||
event = input.parse_mail(msg)
|
||||
event = input.parse_mail(subject)
|
||||
insist { event["subject"] } == "foo : bar"
|
||||
end
|
||||
end
|
||||
|
||||
context "with multiple values for same header" do
|
||||
it "should add 2 values as array in event" do
|
||||
msg.received = "test1"
|
||||
msg.received = "test2"
|
||||
subject.received = "test1"
|
||||
subject.received = "test2"
|
||||
|
||||
config = {"type" => "imap", "host" => "localhost",
|
||||
"user" => "#{user}", "password" => "#{password}"}
|
||||
|
||||
input = LogStash::Inputs::IMAP.new config
|
||||
input.register
|
||||
event = input.parse_mail(msg)
|
||||
event = input.parse_mail(subject)
|
||||
insist { event["received"] } == ["test1", "test2"]
|
||||
end
|
||||
|
||||
it "should add more than 2 values as array in event" do
|
||||
msg.received = "test3"
|
||||
subject.received = "test1"
|
||||
subject.received = "test2"
|
||||
subject.received = "test3"
|
||||
|
||||
config = {"type" => "imap", "host" => "localhost",
|
||||
"user" => "#{user}", "password" => "#{password}"}
|
||||
|
||||
input = LogStash::Inputs::IMAP.new config
|
||||
input.register
|
||||
event = input.parse_mail(msg)
|
||||
event = input.parse_mail(subject)
|
||||
insist { event["received"] } == ["test1", "test2", "test3"]
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue