-
Notifications
You must be signed in to change notification settings - Fork 107
/
visualize_aws_spec.rb
53 lines (46 loc) · 1.64 KB
/
visualize_aws_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
require 'spec_helper'
describe VisualizeAws do
let(:opts) {
{
:source_file => source_file,
:filename => temp_file
}
}
let(:source_file) { File.join(File.dirname(__FILE__), 'dummy.json') }
let(:config) { AwsConfig.new({groups: {'0.0.0.0/0' => '*'}}) }
context 'json to dot file' do
let(:expected_file) { File.join(File.dirname(__FILE__), 'dummy.dot') }
let(:temp_file) { Tempfile.new(%w(aws .dot)) }
it 'should parse json input', :integration => true do
VisualizeAws.new(config, opts).unleash(temp_file.path)
expect(File.read(expected_file)).to eq(temp_file.read)
end
end
context 'json to json file' do
let(:expected_file) { File.join(File.dirname(__FILE__), 'expected.json') }
let(:temp_file) { Tempfile.new(%w(aws .json)) }
it 'should parse json input', :integration => true do
expect(FileUtils).to receive(:copy)
VisualizeAws.new(config, opts).unleash(temp_file.path)
expect(File.read(expected_file)).to eq(temp_file.read)
end
end
if ENV["TEST_ACCESS_KEY"]
context 'ec2 to json file' do
let(:expected_file) { File.join(File.dirname(__FILE__), 'aws_expected.json') }
let(:temp_file) { Tempfile.new(%w(aws .json)) }
let(:opts) {
{
:filename => temp_file,
:secret_key => ENV["TEST_SECRET_KEY"],
:access_key => ENV["TEST_ACCESS_KEY"]
}
}
it 'should read from ec2 account', :integration => true do
expect(FileUtils).to receive(:copy)
VisualizeAws.new(config, opts).unleash(temp_file.path)
expect(File.read(expected_file)).to eq(temp_file.read)
end
end
end
end