forked from Azure/azure-sdk-for-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
152 lines (134 loc) · 4.83 KB
/
Rakefile
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#-------------------------------------------------------------------------
# # Copyright (c) Microsoft and contributors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#--------------------------------------------------------------------------
require 'rake/testtask'
require 'rubygems/package_task'
require 'dotenv/tasks'
gem_spec = eval(File.read('./azure.gemspec'))
Gem::PackageTask.new(gem_spec) do |pkg|
pkg.need_zip = false
pkg.need_tar = false
end
namespace :test do
task :require_environment => :dotenv do
unset_environment = [
ENV.fetch('AZURE_STORAGE_ACCOUNT', nil),
ENV.fetch('AZURE_STORAGE_ACCESS_KEY', nil),
ENV.fetch('AZURE_SERVICEBUS_NAMESPACE', nil),
ENV.fetch('AZURE_SERVICEBUS_ACCESS_KEY', nil),
ENV.fetch('AZURE_MANAGEMENT_CERTIFICATE', nil),
ENV.fetch('AZURE_SUBSCRIPTION_ID', nil)
].include?(nil)
abort '[ABORTING] Configure your environment to run the integration tests' if unset_environment
end
Rake::TestTask.new :unit do |t|
t.pattern = 'test/unit/**/*_test.rb'
t.verbose = true
t.libs = %w(lib test)
end
namespace :unit do
def component_task(component)
Rake::TestTask.new component do |t|
t.pattern = "test/unit/#{component}/**/*_test.rb"
t.verbose = true
t.libs = %w(lib test)
end
end
component_task :affinity_group
component_task :base_management
component_task :blob
component_task :cloud_service_management
component_task :core
component_task :database
component_task :service
component_task :storage_management
component_task :table
component_task :virtual_machine_image_management
component_task :virtual_machine_management
component_task :vnet
end
Rake::TestTask.new :integration do |t|
t.test_files = Dir['test/integration/**/*_test.rb'].reject do |path|
path.include?('database')
end
t.verbose = true
t.libs = %w(lib test)
end
task :integration => :require_environment
namespace :integration do
def component_task(component)
Rake::TestTask.new component do |t|
t.pattern = "test/integration/#{component}/**/*_test.rb"
t.verbose = true
t.libs = %w(lib test)
end
task component => 'test:require_environment'
end
component_task :affinity_group
component_task :blob
component_task :cloud_service
component_task :database
component_task :location
component_task :queue
component_task :service_bus
component_task :storage_management
component_task :table
component_task :vm
component_task :vm_image
component_task :vnet
end
Rake::TestTask.new :recorded do |t|
t.test_files = Dir['test/integration/**/*_test.rb'].reject do |path|
# Reject the test paths those are not yet VCR recorded
# Following three are Azure-Storage gem features and need to be removed when we take dependency on azure-storage gem
path.include?('/blob/') || path.include?('/queue/') || path.include?('/table/')
end
t.verbose = true
t.libs = %w(lib test)
end
namespace :recorded do
def component_task(component)
Rake::TestTask.new component do |t|
t.pattern = "test/integration/#{component}/**/*_test.rb"
t.verbose = true
t.libs = %w(lib test)
end
end
component_task :affinity_group
component_task :cloud_service
component_task :database
component_task :location
component_task :service_bus
component_task :storage_management
component_task :vm
component_task :vm_image
component_task :vnet
end
task :cleanup => :require_environment do
$:.unshift 'lib'
require 'azure'
Azure.configure do |config|
config.access_key = ENV.fetch('AZURE_STORAGE_ACCESS_KEY')
config.account_name = ENV.fetch('AZURE_STORAGE_ACCOUNT')
config.acs_namespace = ENV.fetch('AZURE_SERVICEBUS_NAMESPACE')
config.sb_access_key = ENV.fetch('AZURE_SERVICEBUS_ACCESS_KEY')
config.management_certificate = ENV.fetch('AZURE_MANAGEMENT_CERTIFICATE')
config.management_endpoint = ENV.fetch('AZURE_MANAGEMENT_ENDPOINT')
config.sql_database_management_endpoint = ENV.fetch('AZURE_SQL_DATABASE_MANAGEMENT_ENDPOINT')
config.subscription_id = ENV.fetch('AZURE_SUBSCRIPTION_ID')
end
end
end
task :test => %w(test:unit test:integration)
task :default => :test