forked from aws/aws-sdk-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenv.rb
54 lines (38 loc) · 1.08 KB
/
env.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
54
$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
require 'simplecov'
require 'aws-sdk-resources'
SimpleCov.command_name('test:integration:aws-sdk-resources')
cfg = './integration-test-config.json'
if File.exist?(cfg)
Aws.config = MultiJson.load(File.read(cfg), symbolize_keys: true)
elsif ENV['AWS_INTEGRATION']
# run integration tests, just don't read a configuration file from disk
else
msg = <<-MSG
*** skipping aws-sdk-resource integration tests ***
To enable integration tests, create a #{cfg} file or export AWS_INTEGRATION=1
MSG
puts msg
exit(0)
end
# Track all API calls made
class ApiCallTracker < Seahorse::Client::Plugin
@api_calls = []
class << self
attr_reader :api_calls
def called_operations
api_calls.map { |resp| resp.context.operation_name }
end
end
handle do |context|
response = @handler.call(context)
ApiCallTracker.api_calls << response
response
end
end
Aws.service_added do |_, svc_module, _|
svc_module::Client.add_plugin(ApiCallTracker)
end
Before do |scenario|
ApiCallTracker.api_calls.clear
end