mirror of
https://github.com/fluent/fluentd-ui.git
synced 2026-05-11 22:06:10 +02:00
Add spec for Fluentd::Agent::LocalCommon#pid
This commit is contained in:
parent
ad6aa26cbc
commit
7eddae31b7
29
spec/models/fluentd/agent/local_common_spec.rb
Normal file
29
spec/models/fluentd/agent/local_common_spec.rb
Normal file
@ -0,0 +1,29 @@
|
||||
require 'spec_helper'
|
||||
require 'fileutils'
|
||||
|
||||
describe 'Fluentd::Agent::LocalCommon' do
|
||||
subject { target_class.new.tap{|t| t.pid_file = pid_file_path} }
|
||||
|
||||
let!(:target_class) { Struct.new(:pid_file){ include Fluentd::Agent::LocalCommon } }
|
||||
let!(:pid_file_path) { Rails.root.join('tmp', 'fluentd-test', 'local_common_test.pid').to_s }
|
||||
|
||||
describe '#pid' do
|
||||
context 'no pid file exists' do
|
||||
its(:pid) { should be_nil }
|
||||
end
|
||||
|
||||
context 'empty pid file given' do
|
||||
before { FileUtils.touch pid_file_path }
|
||||
after { FileUtils.rm pid_file_path }
|
||||
|
||||
its(:pid) { should be_nil }
|
||||
end
|
||||
|
||||
context 'valid pid file given' do
|
||||
before { File.write pid_file_path, '99999' }
|
||||
after { FileUtils.rm pid_file_path }
|
||||
|
||||
its(:pid) { should eq(99999) }
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
x
Reference in New Issue
Block a user