logstash/spec/unit/plugin_manager/ui_spec.rb
Pier-Hugues Pellerin 12cfa69215 Feature: A way to install/remove a plugin pack
A pack in this context is a *bundle* of plugins that can be distributed outside of rubygems; it is similar to what ES and kibana are doing, and
the user interface is modeled after them. See https://www.elastic.co/downloads/x-pack

**Do not mix it with the `bin/logstash-plugin pack/unpack` command.**

- it contains one or more plugins that need to be installed
- it is self-contains with the gems and the needed jars
- it is distributed as a zip file
- the file structure needs to follow some rules.

- As a reserved name name on elastic.co download http server
    - `bin/plugin install logstash-mypack` will check on the download server if a pack for the current specific logstash version exist and it will be downloaded, if it doesn't exist we fallback on rubygems.
    - The file on the server will follow this convention `logstash-mypack-{LOGSTASH_VERSION}.zip`

- As a fully qualified url
    - `bin/plugin install http://test.abc/logstash-mypack.zip`, if it exists it will be downloaded and installed if it does not we raise an error.

- As a local file
    - `bin/plugin install file:///tmp/logstash-mypack.zip`, if it exists it will be installed

Fixes #6168
2016-11-17 14:00:02 -05:00

59 lines
1.4 KiB
Ruby

# encoding: utf-8
require "pluginmanager/ui"
describe LogStash::PluginManager do
it "set the a default ui" do
expect(LogStash::PluginManager.ui).to be_kind_of(LogStash::PluginManager::Shell)
end
it "you can override the ui" do
klass = Class.new
LogStash::PluginManager.ui = klass
expect(LogStash::PluginManager.ui).to be(klass)
LogStash::PluginManager.ui = LogStash::PluginManager::Shell.new
end
end
describe LogStash::PluginManager::Shell do
let(:message) { "hello world" }
[:info, :error, :warn].each do |level|
context "Level: #{level}" do
it "display the message to the user" do
expect(subject).to receive(:puts).with(message)
subject.send(level, message)
end
end
end
context "Debug" do
context "when ENV['DEBUG'] is set" do
before do
@previous_value = ENV["DEBUG"]
ENV["DEBUG"] = "1"
end
it "outputs the message" do
expect(subject).to receive(:puts).with(message)
subject.debug(message)
end
after do
ENV["DEBUG"] = @previous_value
end
end
context "when ENV['DEBUG'] is not set" do
@previous_value = ENV["DEBUG"]
ENV.delete("DEBUG")
end
it "doesn't outputs the message" do
expect(subject).not_to receive(:puts).with(message)
subject.debug(message)
end
after do
ENV["DEBUG"] = @previous_value
end
end
end