Sha256: ad0d20d2916a0adc9f0bee8429dd5b35ec9935440411e7851e0700c5502f8709

Contents?: true

Size: 1.33 KB

Versions: 36

Compression:

Stored size: 1.33 KB

Contents

# encoding: utf-8
require "logstash/devutils/rspec/spec_helper"
require "logstash/outputs/s3/size_rotation_policy"
require "logstash/outputs/s3/temporary_file"
require "fileutils"

describe LogStash::Outputs::S3::SizeRotationPolicy do
  subject { described_class.new(size_file) }

  let(:temporary_directory) {  Stud::Temporary.directory }
  let(:temporary_file) { Stud::Temporary.file }
  let(:name) { "foobar" }
  let(:content) { "hello" * 1000 }
  let(:size_file) { 10 } # in bytes
  let(:file) { LogStash::Outputs::S3::TemporaryFile.new(name, temporary_file, temporary_directory) }

  it "returns true if the size on disk is higher than the `size_file`" do
    file.write(content)
    file.fsync
    expect(subject.rotate?(file)).to be_truthy
  end

  it "returns false if the size is inferior than the `size_file`" do
    expect(subject.rotate?(file)).to be_falsey
  end

  it "raises an exception if the `size_file` is 0" do
    expect { described_class.new(0) }.to raise_error(LogStash::ConfigurationError, /need to be greather than 0/)
  end

  it "raises an exception if the `size_file` is < 0" do
    expect { described_class.new(-100) }.to raise_error(LogStash::ConfigurationError, /need to be greather than 0/)
  end

  context "#needs_periodic?" do
    it "return false" do
      expect(subject.needs_periodic?).to be_falsey
    end
  end

end

Version data entries

36 entries across 36 versions & 2 rubygems

Version Path
logstash-integration-aws-7.0.1 spec/outputs/s3/size_rotation_policy_spec.rb
logstash-integration-aws-7.0.0 spec/outputs/s3/size_rotation_policy_spec.rb
logstash-output-s3-4.3.7 spec/outputs/s3/size_rotation_policy_spec.rb
logstash-output-s3-4.3.6 spec/outputs/s3/size_rotation_policy_spec.rb
logstash-integration-aws-0.1.0.pre spec/outputs/s3/size_rotation_policy_spec.rb
logstash-output-s3-4.3.5 spec/outputs/s3/size_rotation_policy_spec.rb
logstash-output-s3-4.3.4 spec/outputs/s3/size_rotation_policy_spec.rb
logstash-output-s3-4.3.3 spec/outputs/s3/size_rotation_policy_spec.rb
logstash-output-s3-4.3.2 spec/outputs/s3/size_rotation_policy_spec.rb
logstash-output-s3-4.3.1 spec/outputs/s3/size_rotation_policy_spec.rb
logstash-output-s3-4.3.0 spec/outputs/s3/size_rotation_policy_spec.rb
logstash-output-s3-4.2.0 spec/outputs/s3/size_rotation_policy_spec.rb
logstash-output-s3-4.1.10 spec/outputs/s3/size_rotation_policy_spec.rb
logstash-output-s3-4.1.9 spec/outputs/s3/size_rotation_policy_spec.rb
logstash-output-s3-4.1.8 spec/outputs/s3/size_rotation_policy_spec.rb
logstash-output-s3-4.1.7 spec/outputs/s3/size_rotation_policy_spec.rb
logstash-output-s3-4.1.6 spec/outputs/s3/size_rotation_policy_spec.rb
logstash-output-s3-4.1.5 spec/outputs/s3/size_rotation_policy_spec.rb
logstash-output-s3-4.1.4 spec/outputs/s3/size_rotation_policy_spec.rb
logstash-output-s3-4.1.3 spec/outputs/s3/size_rotation_policy_spec.rb