-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
56 lines (46 loc) · 1.71 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
# frozen_string_literal: true
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
require_relative 'test/support/rake'
namespace :test do
desc 'Run unit tests'
RSpec::Core::RakeTask.new(:unit) do |t|
t.pattern = 'test/unit/**/*_spec.rb'
end
desc "Run acceptance tests\n" \
"Terraform versions can be passed by a comma/space separated argument or \n" \
'TERRAFORM_VERSIONS environment variable.'
task :acceptance, [:terraform_versions] do |t, args|
tasks = namespace(t.name) {}.tasks # Find all acceptance test tasks
TestSupport::Rake.terraform_versions(args, default: 'latest').each do |v|
rake_output_message "#########################################################\n" \
"# Running with Terraform version: #{v}\n\n"
tasks.each do |task|
# Force running the tasks multiple times (with different Terraform versions)
task.reenable
task.invoke(v)
rake_output_message ''
end
end
end
namespace :acceptance do
desc ''
RSpec::Core::RakeTask.new(:spec, [:terraform_version]) do |t, args|
t.pattern = 'test/acceptance/**/*_spec.rb'
ENV['TERRAFORM_VERSION'] = args[:terraform_version]
end
task :example, [:terraform_version] do |_, args|
TestSupport::Rake.run_tf(
tf_command: 'apply',
tf_env: 'test',
tf_options: ['--debug'],
terraform_version: args[:terraform_version],
module_dir: 'test/acceptance/fixtures/example',
cleanup_globs: %w[*.tfstate tf_example_test]
)
end
end
end
desc 'Run all tests'
task :test, [:terraform_versions] => %w[test:unit test:acceptance]
task default: 'test:unit'