mirror of
https://github.com/fluent/fluentd-ui.git
synced 2025-08-08 15:27:08 +02:00
40 lines
1.0 KiB
Ruby
40 lines
1.0 KiB
Ruby
require "test_helper"
|
|
|
|
class Fluentd
|
|
class AgentsControllerTest < ActionDispatch::IntegrationTest
|
|
setup do
|
|
@log = Object.new
|
|
@agent = Object.new
|
|
@fluentd = FactoryBot.build(:fluentd)
|
|
stub(@agent).log { @log }
|
|
stub(@fluentd).agent { @agent }
|
|
stub(Fluentd).instance { @fluentd }
|
|
|
|
|
|
user = FactoryBot.build(:user)
|
|
post(sessions_path(session: { name: user.name, password: user.password }))
|
|
|
|
|
|
end
|
|
|
|
data("stop" => "stop",
|
|
"start" => "start",
|
|
"restart" => "restart",
|
|
"reload" => "reload")
|
|
test "the action succeed" do |action|
|
|
mock(@agent).__send__(action) { true }
|
|
put(__send__("#{action}_daemon_agent_path"))
|
|
end
|
|
|
|
data("stop" => "stop",
|
|
"start" => "start",
|
|
"restart" => "restart",
|
|
"reload" => "reload")
|
|
test "the action failure" do |action|
|
|
mock(@agent).__send__(action) { false }
|
|
mock(@log).tail(1) { ["dummylog"] } unless action == "stop"
|
|
put(__send__("#{action}_daemon_agent_path"))
|
|
end
|
|
end
|
|
end
|