From 544ddfd36077fb43c0a6d803ba2dd3fca59deaf8 Mon Sep 17 00:00:00 2001 From: abdullahzen Date: Tue, 15 Dec 2020 03:18:48 -0500 Subject: [PATCH] Added bucket name to object returned by sqs poller in the unit tests Fixed wrong variable name in the input plugin Signed-off-by: abdullahzen --- lib/fluent/plugin/in_s3.rb | 4 ++-- test/test_in_s3.rb | 26 +++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/lib/fluent/plugin/in_s3.rb b/lib/fluent/plugin/in_s3.rb index c270f53..1244b49 100644 --- a/lib/fluent/plugin/in_s3.rb +++ b/lib/fluent/plugin/in_s3.rb @@ -156,8 +156,8 @@ def start raise "#{bucket} is not found." unless @buckets[bucket].exists? end else - @buckets[bucket] = @s3.bucket(@s3_buckets) - raise "#{bucket} is not found." unless @buckets[bucket].exists? + @buckets[@s3_buckets] = @s3.bucket(@s3_buckets) + raise "#{@s3_buckets} is not found." unless @buckets[@s3_buckets].exists? end check_apikeys if @check_apikey_on_start diff --git a/test/test_in_s3.rb b/test/test_in_s3.rb index 01b2ecd..6995200 100644 --- a/test/test_in_s3.rb +++ b/test/test_in_s3.rb @@ -228,7 +228,7 @@ def setup_mocks mock(Aws::S3::Client).new(anything).at_least(0) { @s3_client } @s3_resource = mock(Aws::S3::Resource.new(client: @s3_client)) mock(Aws::S3::Resource).new(client: @s3_client) { @s3_resource } - @s3_bucket = mock(Aws::S3::Bucket.new(name: "test", + @s3_bucket = mock(Aws::S3::Bucket.new(name: "test_bucket", client: @s3_client)) @s3_bucket.exists? { true } @s3_resource.bucket(anything) { @s3_bucket } @@ -278,6 +278,9 @@ def test_one_record "s3" => { "object" => { "key" => "test_key" + }, + "bucket" => { + "name"=> "test_bucket" } } } @@ -313,6 +316,9 @@ def test_one_record_with_metadata "s3" => { "object" => { "key" => "test_key" + }, + "bucket" => { + "name"=> "test_bucket" } } } @@ -348,6 +354,9 @@ def test_one_record_url_encoded "s3" => { "object" => { "key" => "test+key" + }, + "bucket" => { + "name"=> "test_bucket" } } } @@ -383,6 +392,9 @@ def test_one_record_url_encoded_with_metadata "s3" => { "object" => { "key" => "test+key" + }, + "bucket" => { + "name"=> "test_bucket" } } } @@ -418,6 +430,9 @@ def test_one_record_multi_line "s3" => { "object" => { "key" => "test_key" + }, + "bucket" => { + "name"=> "test_bucket" } } } @@ -458,6 +473,9 @@ def test_one_record_multi_line_with_metadata "s3" => { "object" => { "key" => "test_key" + }, + "bucket" => { + "name"=> "test_bucket" } } } @@ -506,6 +524,9 @@ def test_gzip_single_stream "s3" => { "object" => { "key" => "test_key" + }, + "bucket" => { + "name"=> "test_bucket" } } } @@ -557,6 +578,9 @@ def test_gzip_multiple_steams "s3" => { "object" => { "key" => "test_key" + }, + "bucket" => { + "name"=> "test_bucket" } } }