|
1 | 1 | # encoding: utf-8 |
2 | | -require "logstash/devutils/rspec/spec_helper" |
3 | | -require "logstash/inputs/cloudwatch_logs" |
| 2 | +require 'logstash/devutils/rspec/spec_helper' |
| 3 | +require 'logstash/inputs/cloudwatch_logs' |
| 4 | +require 'aws-sdk-resources' |
| 5 | +require 'aws-sdk' |
4 | 6 |
|
5 | 7 | describe LogStash::Inputs::CloudWatch_Logs do |
6 | 8 | let(:config) { |
|
18 | 20 | end |
19 | 21 |
|
20 | 22 |
|
21 | | - context "when interrupting the plugin" do |
22 | | - let(:config) { super.merge({ "interval" => 5 }) } |
| 23 | + context 'when interrupting the plugin' do |
| 24 | + let(:config) {super.merge({'interval' => 5})} |
23 | 25 |
|
24 | 26 | before do |
25 | | - expect_any_instance_of(LogStash::Inputs::CloudWatch_Logs).to receive(:process_group) |
| 27 | + expect_any_instance_of(LogStash::Inputs::CloudWatch_Logs).to receive(:process_group).and_return(nil) |
26 | 28 | end |
27 | 29 |
|
28 | | - it_behaves_like "an interruptible input plugin" |
| 30 | + it_behaves_like 'an interruptible input plugin' |
29 | 31 | end |
30 | 32 |
|
31 | 33 | describe '#register' do |
32 | 34 | subject {LogStash::Inputs::CloudWatch_Logs.new(config)} |
33 | 35 |
|
34 | | - it "registers succesfully" do |
| 36 | + it 'registers succesfully' do |
35 | 37 | expect {subject.register}.to_not raise_error |
36 | 38 | end |
37 | 39 | end |
| 40 | + |
| 41 | + describe '#find_log_groups without prefix true' do |
| 42 | + context 'with an array in the config' do |
| 43 | + subject {LogStash::Inputs::CloudWatch_Logs.new(config)} |
| 44 | + |
| 45 | + it 'passes through configuration' do |
| 46 | + expect(subject.find_log_groups).to eq(['sample-log-group']) |
| 47 | + end |
| 48 | + end |
| 49 | + |
| 50 | + context 'with a single string in the log_group' do |
| 51 | + subject {LogStash::Inputs::CloudWatch_Logs.new(config.merge({'log_group' => 'sample-log-group-string'}))} |
| 52 | + |
| 53 | + it 'array-ifies the single string' do |
| 54 | + expect(subject.find_log_groups).to eq(['sample-log-group-string']) |
| 55 | + end |
| 56 | + end |
| 57 | + end |
| 58 | + |
| 59 | + # describe '#find_log_groups with prefix true' do |
| 60 | + # subject {LogStash::Inputs::CloudWatch_Logs.new(config.merge({'log_group_prefix' => true}))} |
| 61 | + # |
| 62 | + # before(:each) {subject.register} |
| 63 | + # |
| 64 | + # it 'should create list of prefixes' do |
| 65 | + # expect_any_instance_of(Aws::CloudWatchLogs::Resource).to receive(:describe_log_groups).and_return({'log_groups' => [{'log_group_name' => '1'},{'log_group_name' => '2'}]}) |
| 66 | + # expect(subject.find_log_groups).to eq(['sample-log-group-1', 'sample-log-group-2']) |
| 67 | + # end |
| 68 | + # end |
| 69 | + |
38 | 70 | end |
0 commit comments