Sha256: 533de1010daca3f2aff3f8e040e873b6c4f8d190af6592a00ad345d7690dfbce
Contents?: true
Size: 1.29 KB
Versions: 3
Compression:
Stored size: 1.29 KB
Contents
# encoding: utf-8 require "logstash/outputs/exec" require "logstash/event" require "logstash/devutils/rspec/spec_helper" require "tempfile" describe LogStash::Outputs::Exec do let(:event) { LogStash::Event.new({ "params" => "1234" }) } let(:output) { "1" } let(:command) { "echo #{output}" } let(:config) do { "command" => command } end let(:error_message) { "Oulala" } let(:stderr) { Tempfile.new(error_message) } let(:stdout) { Tempfile.new(output) } let(:stdin) { Tempfile.new("") } subject { described_class.new(config) } it "receive a command and execute it" do expect(Open3).to receive(:popen3).with(command) subject.receive(event) end context "when debugging" do before :each do allow(subject.logger).to receive(:debug?).and_return(true) expect(Open3).to receive(:popen3).with(command).and_yield(stdin, stdout, stderr) end it "register the stdout and stderr to the logger" do expect(subject.logger).to receive(:pipe).with(stdout => :debug, stderr => :debug) subject.receive(event) end end context "When debugging is off" do context "when quiet is off" do it "write output to the terminal" do expect(subject.logger).to receive(:terminal).with(output) subject.receive(event) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
logstash-output-exec-3.0.3 | spec/outputs/exec_spec.rb |
logstash-output-exec-2.0.5 | spec/outputs/exec_spec.rb |
logstash-output-exec-3.0.2 | spec/outputs/exec_spec.rb |