spec/outputs/http_spec.rb in logstash-output-http-4.0.0 vs spec/outputs/http_spec.rb in logstash-output-http-4.1.0
- old
+ new
@@ -100,11 +100,13 @@
describe LogStash::Outputs::Http do
# Wait for the async request to finish in this spinlock
# Requires pool_max to be 1
let(:port) { PORT }
- let(:event) { LogStash::Event.new("message" => "hi") }
+ let(:event) {
+ LogStash::Event.new({"message" => "hi"})
+ }
let(:url) { "http://localhost:#{port}/good" }
let(:method) { "post" }
shared_examples("verb behavior") do |method|
let(:verb_behavior_config) { {"url" => url, "http_method" => method, "pool_max" => 1} }
@@ -223,11 +225,13 @@
end
end
describe "integration tests" do
let(:url) { "http://localhost:#{port}/good" }
- let(:event) { LogStash::Event.new("foo" => "bar", "baz" => "bot")}
+ let(:event) {
+ LogStash::Event.new("foo" => "bar", "baz" => "bot", "user" => "McBest")
+ }
subject { LogStash::Outputs::Http.new(config) }
before do
subject.register
@@ -263,12 +267,39 @@
include_examples("a received event")
end
describe "sending a mapped event" do
let(:config) {
- {"url" => url, "http_method" => "post", "pool_max" => 1, "mapping" => {"blah" => "X %{foo}"}}
+ {"url" => url, "http_method" => "post", "pool_max" => 1, "mapping" => {"blah" => "X %{foo}"} }
}
let(:expected_body) { LogStash::Json.dump("blah" => "X #{event.get("foo")}") }
+ let(:expected_content_type) { "application/json" }
+
+ include_examples("a received event")
+ end
+
+ describe "sending a mapped, nested event" do
+ let(:config) {
+ {
+ "url" => url,
+ "http_method" => "post",
+ "pool_max" => 1,
+ "mapping" => {
+ "host" => "X %{foo}",
+ "event" => {
+ "user" => "Y %{user}"
+ }
+ }
+ }
+ }
+ let(:expected_body) {
+ LogStash::Json.dump({
+ "host" => "X #{event.get("foo")}",
+ "event" => {
+ "user" => "Y #{event.get("user")}"
+ }
+ })
+ }
let(:expected_content_type) { "application/json" }
include_examples("a received event")
end
end