|
5 | 5 | require "stud/temporary" |
6 | 6 |
|
7 | 7 | describe LogStash::Inputs::S3::ProcessingPolicyValidator do |
8 | | - let(:remote_file) { RemoteFile.new(s3_object) } |
| 8 | + let(:logger) { double("logger").as_null_object } |
| 9 | + let(:gzip_pattern) { "*.gz" } |
| 10 | + let(:remote_file) { LogStash::Inputs::S3::RemoteFile.new(s3_object, logger, gzip_pattern) } |
9 | 11 | let(:s3_object) { double("s3_object", :key => "hola", :content_length => 20, :last_modified => Time.now-60) } |
10 | 12 |
|
11 | 13 | let(:validator_1) { LogStash::Inputs::S3::ProcessingPolicyValidator::SkipEmptyFile } |
|
15 | 17 | subject { described_class } |
16 | 18 |
|
17 | 19 | it "accepts multiples validator" do |
18 | | - expect(subject.new(validator_1, validator_2).count).to eq(2) |
| 20 | + expect(subject.new(logger, validator_1, validator_2).count).to eq(2) |
19 | 21 | end |
20 | 22 |
|
21 | 23 | it "accepts one validator" do |
22 | | - expect(subject.new(validator_1).count).to eq(1) |
| 24 | + expect(subject.new(logger, validator_1).count).to eq(1) |
23 | 25 | end |
24 | 26 | end |
25 | 27 |
|
26 | 28 | context "#add_policy" do |
27 | | - subject { described_class.new(validator_1) } |
| 29 | + subject { described_class.new(logger, validator_1) } |
28 | 30 |
|
29 | 31 | it "allows to add more validators" do |
30 | 32 | expect(subject.count).to eq(1) |
|
43 | 45 | end |
44 | 46 |
|
45 | 47 | context "#process?" do |
46 | | - subject { described_class.new(validator_1, validator_2) } |
| 48 | + subject { described_class.new(logger, validator_1, validator_2) } |
47 | 49 |
|
48 | 50 | it "execute the validator in declarations order" do |
49 | 51 | expect(validator_1).to receive(:process?).ordered.and_return(true) |
|
133 | 135 | let(:older_than) { 3600 } |
134 | 136 | let(:s3_object) { double("remote_file", :etag => "1234", :bucket_name => "mon-bucket", :key => "hola", :content_length => 100, :last_modified => Time.now) } |
135 | 137 | let(:sincedb_path) { Stud::Temporary.file.path } |
136 | | - let(:sincedb) { LogStash::Inputs::S3::SinceDB.new(sincedb_path, older_than) } |
| 138 | + let(:logger) { double("logger").as_null_object } |
| 139 | + |
| 140 | + before do |
| 141 | + # Avoid starting the bookkeeping thread since it will keep running after the test |
| 142 | + allow_any_instance_of(LogStash::Inputs::S3::SinceDB).to receive(:start_bookkeeping) |
| 143 | + end |
| 144 | + |
| 145 | + let(:sincedb) { LogStash::Inputs::S3::SinceDB.new(sincedb_path, older_than, logger) } |
137 | 146 |
|
138 | 147 | subject { described_class.new(sincedb) } |
139 | 148 |
|
|
0 commit comments