Skip to content

Commit

Permalink
fix current time to generate a fixed file path with timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
tagomoris committed Oct 6, 2016
1 parent 56de259 commit 33a8699
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions test/plugin/test_out_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,18 @@ def create_driver(conf = CONFIG)
end

test 'configuration error raised if specified directory via template is not writable' do
conf = config_element('match', '**', {
'path' => "#{TMP_DIR}/prohibited/${tag}/file.%Y%m%d.log",
}, [ config_element('buffer', 'time,tag', {'timekey' => 86400}) ])
FileUtils.mkdir_p("#{TMP_DIR}/prohibited")
File.chmod(0555, "#{TMP_DIR}/prohibited")
assert_raise Fluent::ConfigError.new("out_file: `#{TMP_DIR}/prohibited/a/file.20161004.log_**.log` is not writable") do
create_driver(conf)
Timecop.freeze(Time.parse("2016-10-04 21:33:27 UTC"))

This comment has been minimized.

Copy link
@okkez

okkez Oct 6, 2016

Contributor

Maybe we can use Timecop.frees(Time.parse("2016-10-04 21:33:27 UTC")) do ... end here

This comment has been minimized.

Copy link
@tagomoris

tagomoris Oct 6, 2016

Author Member

Oh, good to know.

begin
conf = config_element('match', '**', {
'path' => "#{TMP_DIR}/prohibited/${tag}/file.%Y%m%d.log",
}, [ config_element('buffer', 'time,tag', {'timekey' => 86400, 'timekey_zone' => '+0000'}) ])
FileUtils.mkdir_p("#{TMP_DIR}/prohibited")
File.chmod(0555, "#{TMP_DIR}/prohibited")
assert_raise Fluent::ConfigError.new("out_file: `#{TMP_DIR}/prohibited/a/file.20161004.log_**.log` is not writable") do
create_driver(conf)
end
ensure
Timecop.return
end
end

Expand Down

0 comments on commit 33a8699

Please sign in to comment.