tfmodtest 0.0.1.rc3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +19 -17
- data/Gemfile +4 -4
- data/LICENSE +12 -12
- data/README.md +115 -118
- data/Rakefile +2 -2
- data/lib/tfmodtest.rb +4 -4
- data/lib/tfmodtest/module_helper.rb +47 -47
- data/lib/tfmodtest/module_tasks.rb +2 -2
- data/lib/tfmodtest/module_test.rb +56 -56
- data/lib/tfmodtest/version.rb +3 -3
- data/tfmodtest.gemspec +28 -28
- metadata +17 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7b66029ea114e96123870b6c2befecc43a830b3abd12c60abb3a67177f9949bc
|
4
|
+
data.tar.gz: b69789199480a5c1f39159f766d0cab786fd608200710ecd19ed399c04cdae3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 172c87c9095d5df93ead722c24ebca2ab7dd2884b06282e86d8f3a1dd2fe6f8fa9247da621de7db517c5a15aa23da0093574cb72459a75e5957b5f6f8cc3db5b
|
7
|
+
data.tar.gz: 1bf41456ee36d7479b5967983de48f3e795ac6ae9aaae60f379386acae09bf547ee766ece6cb7b5ff7f967db2f77294c16c4bd4d7c644b584bffcf486e5a0cc4
|
data/.travis.yml
CHANGED
@@ -1,17 +1,19 @@
|
|
1
|
-
sudo: false
|
2
|
-
language: ruby
|
3
|
-
rvm:
|
4
|
-
- 2.
|
5
|
-
|
6
|
-
-
|
7
|
-
|
8
|
-
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
1
|
+
sudo: false
|
2
|
+
language: ruby
|
3
|
+
rvm:
|
4
|
+
- 2.5
|
5
|
+
- 2.6
|
6
|
+
- 2.7
|
7
|
+
before_install:
|
8
|
+
- gem install bundler
|
9
|
+
os:
|
10
|
+
- linux
|
11
|
+
- osx
|
12
|
+
deploy:
|
13
|
+
provider: rubygems
|
14
|
+
api_key:
|
15
|
+
secure: cEI9LKkhADHmTGsiCsqUwhjVAW/qtWd7NhPMPsgEvPbHFB6qO/zmocbceEWIcQT3WKp9i/RzSF5zrD3cmCEMmjs7e4XaVFn0NOoDFBQIZgWk5PfbGMlVaCArGJ80tbhCFLFfVqyw7pR4OtP5ov6nULi8HBdfq5ffmjC92Pg0phWDTsyKGHesXuvMUjyx8y61hZOaXkkYd5T8MaN/9ahdM0r6hp2XX5RZDWm0712b2qKO/9gBH1WUaYyiawiNmHtLsUwgobZC6s8i5EObqAY0EbFBr69vUy7mQvJtWUGQJP89RdZ9jpqOHFoSsYuBWhYixWUOmgoV2z4jBUYGGIU+Il+57SjQPB4bH5FK3OvSD6ctN7kbEWnenYhJsn2UnVtR68PrXu/xvrCmfKcQ5NgNb+eJLInjeE42OH3+Oqx2RAjGRB8yV8a+WW7rymXZ89UHYODZd8dhbRwMH8nkfblMa6f7uZXeUF9wtahh2d12xj4APLvQLN24EMX46/TXiP2IjYzeYQf4loG0SnDjds94g9aTX4SdybiIdSrThyKcgNwlrQtKq4Gp0/yfCQxtfhqcZDoPVOU3Rts3uITiqV4/jqyF2UeFPfdhZuEaAsy9OlnA9fgfN9L70b/ylhHbJfkyzVIUP8o/7VZzMqyiyXctYM9+XM4408GALFdqPwdDFM4=
|
16
|
+
gem: tfmodtest
|
17
|
+
on:
|
18
|
+
tags: true
|
19
|
+
repo: vistaprint/tfmodtest
|
data/Gemfile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
# Specify your gem's dependencies in terraform_module_testing.gemspec
|
4
|
-
gemspec
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in terraform_module_testing.gemspec
|
4
|
+
gemspec
|
data/LICENSE
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
Copyright 2017 Cimpress
|
2
|
-
|
3
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
you may not use this file except in compliance with the License.
|
5
|
-
You may obtain a copy of the License at
|
6
|
-
|
7
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
|
9
|
-
Unless required by applicable law or agreed to in writing, software
|
10
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
See the License for the specific language governing permissions and
|
1
|
+
Copyright 2017 Cimpress
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
13
|
limitations under the License.
|
data/README.md
CHANGED
@@ -1,118 +1,115 @@
|
|
1
|
-
# Terraform Module Testing
|
2
|
-
|
3
|
-
[![Build Status](https://travis-ci.org/vistaprint/tfmodtest.svg?branch=master)](https://travis-ci.org/vistaprint/tfmodtest)
|
4
|
-
[![Gem Version](https://badge.fury.io/rb/tfmodtest.svg)](https://badge.fury.io/rb/tfmodtest)
|
5
|
-
|
6
|
-
Terraform Module Testing is a set of rake tasks to easily enable testing for Terraform Module developement. It allows developers to specify tests in a rake task to test remote infrastructure is created as expected when using a module. It then destroys the environment after the test has run.
|
7
|
-
|
8
|
-
Currently this repository is tightly coupled with AWS and has not been tested to work with other providers. We are actively working to change this and hope to have a more generic solution soon. If you would like to see support for your favourite cloud provider please have submit a pull request implementing support and we will be more than happy to merge your changes in.
|
9
|
-
|
10
|
-
# Installation
|
11
|
-
Add this line to your application's Gemfile:
|
12
|
-
|
13
|
-
`gem 'tfmodtest'`
|
14
|
-
|
15
|
-
And then execute:
|
16
|
-
|
17
|
-
`$ bundle`
|
18
|
-
|
19
|
-
Or install it yourself as:
|
20
|
-
|
21
|
-
`$ gem install tfmodtest`
|
22
|
-
|
23
|
-
## Getting started
|
24
|
-
|
25
|
-
### A Minimal Rakefile
|
26
|
-
|
27
|
-
In the root of your repository add a `Rakefile` with the following contents:
|
28
|
-
|
29
|
-
```ruby
|
30
|
-
require 'tfmodtest/module_tasks'
|
31
|
-
```
|
32
|
-
|
33
|
-
# Adding tests
|
34
|
-
|
35
|
-
In your repository create `test/<my_module>/Rakefile` and add:
|
36
|
-
|
37
|
-
```ruby
|
38
|
-
namespace '<your_modules_namespace>' do
|
39
|
-
# Required: Import TerraformDevKit base rake tasks.
|
40
|
-
# Set the root path of our tests to our location.
|
41
|
-
# TerraformDevKit uses this path as the base from where
|
42
|
-
# all operations are run.
|
43
|
-
ROOT_PATH = File.dirname(File.expand_path(__FILE__))
|
44
|
-
spec = Gem::Specification.find_by_name 'TerraformDevKit'
|
45
|
-
load "#{spec.gem_dir}/tasks/devkit.rake"
|
46
|
-
|
47
|
-
# Optional: Use RSpec to run tests.
|
48
|
-
begin
|
49
|
-
require 'rspec/core/rake_task'
|
50
|
-
RSpec::Core::RakeTask.new(:spec)
|
51
|
-
rescue LoadError
|
52
|
-
raise 'Rspec not found'
|
53
|
-
end
|
54
|
-
|
55
|
-
# Required: Add a hook into TerraformDevKit to
|
56
|
-
# run tests for your module.
|
57
|
-
task :custom_test, [:env] => :spec
|
58
|
-
end
|
59
|
-
```
|
60
|
-
|
61
|
-
The `custom_test` task is a hook in TerraformDevKit that is called once all the infrastructure is created. You can see a full list of useful hooks in TerraformDevKit [here](https://github.com/vistaprint/TerraformDevKit#tasks-and-hooks)
|
62
|
-
|
63
|
-
Create `test/<my_module>/config/config-dev.yml` that contains:
|
64
|
-
|
65
|
-
```yml
|
66
|
-
terraform-version: 0.
|
67
|
-
project-name: my module tests
|
68
|
-
aws:
|
69
|
-
profile: <profile>
|
70
|
-
region: <region>
|
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
|
-
it { should
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
To install this gem locally run `rake install` You should then be able to reference it in your local projects.
|
117
|
-
|
118
|
-
|
1
|
+
# Terraform Module Testing
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/vistaprint/tfmodtest.svg?branch=master)](https://travis-ci.org/vistaprint/tfmodtest)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/tfmodtest.svg)](https://badge.fury.io/rb/tfmodtest)
|
5
|
+
|
6
|
+
Terraform Module Testing is a set of rake tasks to easily enable testing for Terraform Module developement. It allows developers to specify tests in a rake task to test remote infrastructure is created as expected when using a module. It then destroys the environment after the test has run.
|
7
|
+
|
8
|
+
Currently this repository is tightly coupled with AWS and has not been tested to work with other providers. We are actively working to change this and hope to have a more generic solution soon. If you would like to see support for your favourite cloud provider please have submit a pull request implementing support and we will be more than happy to merge your changes in.
|
9
|
+
|
10
|
+
# Installation
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
`gem 'tfmodtest'`
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
`$ bundle`
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
`$ gem install tfmodtest`
|
22
|
+
|
23
|
+
## Getting started
|
24
|
+
|
25
|
+
### A Minimal Rakefile
|
26
|
+
|
27
|
+
In the root of your repository add a `Rakefile` with the following contents:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
require 'tfmodtest/module_tasks'
|
31
|
+
```
|
32
|
+
|
33
|
+
# Adding tests
|
34
|
+
|
35
|
+
In your repository create `test/<my_module>/Rakefile` and add:
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
namespace '<your_modules_namespace>' do
|
39
|
+
# Required: Import TerraformDevKit base rake tasks.
|
40
|
+
# Set the root path of our tests to our location.
|
41
|
+
# TerraformDevKit uses this path as the base from where
|
42
|
+
# all operations are run.
|
43
|
+
ROOT_PATH = File.dirname(File.expand_path(__FILE__))
|
44
|
+
spec = Gem::Specification.find_by_name 'TerraformDevKit'
|
45
|
+
load "#{spec.gem_dir}/tasks/devkit.rake"
|
46
|
+
|
47
|
+
# Optional: Use RSpec to run tests.
|
48
|
+
begin
|
49
|
+
require 'rspec/core/rake_task'
|
50
|
+
RSpec::Core::RakeTask.new(:spec)
|
51
|
+
rescue LoadError
|
52
|
+
raise 'Rspec not found'
|
53
|
+
end
|
54
|
+
|
55
|
+
# Required: Add a hook into TerraformDevKit to
|
56
|
+
# run tests for your module.
|
57
|
+
task :custom_test, [:env] => :spec
|
58
|
+
end
|
59
|
+
```
|
60
|
+
|
61
|
+
The `custom_test` task is a hook in TerraformDevKit that is called once all the infrastructure is created. You can see a full list of useful hooks in TerraformDevKit [here](https://github.com/vistaprint/TerraformDevKit#tasks-and-hooks)
|
62
|
+
|
63
|
+
Create `test/<my_module>/config/config-dev.yml` that contains:
|
64
|
+
|
65
|
+
```yml
|
66
|
+
terraform-version: 0.12.24
|
67
|
+
project-name: my module tests
|
68
|
+
aws:
|
69
|
+
profile: <profile>
|
70
|
+
region: <region>
|
71
|
+
```
|
72
|
+
|
73
|
+
This configuration determines where Terraform will create the infrastructure during test execution.
|
74
|
+
|
75
|
+
Finally to create your infrastructure under test place a `main.tf.mustache` file in `test/<my_module>`. This is the file TerraformDevKit will use to create you infrastructure.
|
76
|
+
|
77
|
+
```hcl
|
78
|
+
provider "aws" {
|
79
|
+
# Use the profile specified in config/config-dev.yml
|
80
|
+
profile = "{{Profile}}"
|
81
|
+
region = "us-east-1"
|
82
|
+
}
|
83
|
+
|
84
|
+
resource "aws_s3_bucket" "b" {
|
85
|
+
# Use the Environment name as part of the bucket name
|
86
|
+
bucket = "{{Environment}}my-tf-test-bucket"
|
87
|
+
acl = "private"
|
88
|
+
|
89
|
+
tags {
|
90
|
+
Name = "My bucket"
|
91
|
+
Environment = "Dev"
|
92
|
+
}
|
93
|
+
}
|
94
|
+
```
|
95
|
+
|
96
|
+
## Optional but recommended
|
97
|
+
|
98
|
+
[`awspec`](https://github.com/k1LoW/awspec) is a Ruby gem for running `rspec` tests against AWS infrastructure. It eases the pain of running tests against AWS:
|
99
|
+
|
100
|
+
```ruby
|
101
|
+
describe cloudwatch_alarm("www.example.com-5xxErrorRate") do
|
102
|
+
it { should exist }
|
103
|
+
it { should belong_to_metric('5xxErrorRate').namespace('AWS/CloudFront') }
|
104
|
+
end
|
105
|
+
```
|
106
|
+
|
107
|
+
To start using `awspec` follow the [Getting Started ](https://github.com/k1LoW/awspec#getting-started)
|
108
|
+
|
109
|
+
# Requirements
|
110
|
+
|
111
|
+
* Terraform 0.12.0 or above
|
112
|
+
|
113
|
+
# Development
|
114
|
+
|
115
|
+
To install this gem locally run `rake install` You should then be able to reference it in your local projects.
|
data/Rakefile
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
require 'bundler/gem_tasks'
|
2
|
-
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
|
3
3
|
task :default => [:build]
|
data/lib/tfmodtest.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'tfmodtest/module_helper'
|
2
|
-
require 'tfmodtest/module_tasks'
|
3
|
-
require 'tfmodtest/module_test'
|
4
|
-
require 'tfmodtest/version.rb'
|
1
|
+
require 'tfmodtest/module_helper'
|
2
|
+
require 'tfmodtest/module_tasks'
|
3
|
+
require 'tfmodtest/module_test'
|
4
|
+
require 'tfmodtest/version.rb'
|
@@ -1,47 +1,47 @@
|
|
1
|
-
require 'socket'
|
2
|
-
require 'yaml'
|
3
|
-
|
4
|
-
require 'tfmodtest'
|
5
|
-
|
6
|
-
TMT = TFModTest
|
7
|
-
|
8
|
-
HOSTNAME = Socket.gethostname
|
9
|
-
DATE = Time.new.strftime('%y%m%d%H%M%S')
|
10
|
-
DEFAULT_PREFIX = "TMT#{HOSTNAME}#{DATE}".freeze
|
11
|
-
|
12
|
-
module TFModTest
|
13
|
-
class ModuleHelper
|
14
|
-
include Rake::DSL if defined? Rake::DSL
|
15
|
-
|
16
|
-
class << self
|
17
|
-
def install_tasks
|
18
|
-
new.install
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def install
|
23
|
-
task default: [:preflight]
|
24
|
-
|
25
|
-
def run_task(task_name)
|
26
|
-
TMT::ModuleTestRepository.each do |m|
|
27
|
-
m.run_task(task_name)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
desc 'Runs all the tests'
|
32
|
-
task :preflight do
|
33
|
-
run_task('preflight')
|
34
|
-
end
|
35
|
-
|
36
|
-
desc 'Destroy any remaining infrastructure'
|
37
|
-
task :destroy do
|
38
|
-
run_task('destroy')
|
39
|
-
end
|
40
|
-
|
41
|
-
desc 'Cleans up the project (after destroying infrastructure)'
|
42
|
-
task :clean do
|
43
|
-
run_task('clean')
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
1
|
+
require 'socket'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
require 'tfmodtest'
|
5
|
+
|
6
|
+
TMT = TFModTest
|
7
|
+
|
8
|
+
HOSTNAME = Socket.gethostname
|
9
|
+
DATE = Time.new.strftime('%y%m%d%H%M%S')
|
10
|
+
DEFAULT_PREFIX = "TMT#{HOSTNAME}#{DATE}".freeze
|
11
|
+
|
12
|
+
module TFModTest
|
13
|
+
class ModuleHelper
|
14
|
+
include Rake::DSL if defined? Rake::DSL
|
15
|
+
|
16
|
+
class << self
|
17
|
+
def install_tasks
|
18
|
+
new.install
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def install
|
23
|
+
task default: [:preflight]
|
24
|
+
|
25
|
+
def run_task(task_name)
|
26
|
+
TMT::ModuleTestRepository.each do |m|
|
27
|
+
m.run_task(task_name)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
desc 'Runs all the tests'
|
32
|
+
task :preflight do
|
33
|
+
run_task('preflight')
|
34
|
+
end
|
35
|
+
|
36
|
+
desc 'Destroy any remaining infrastructure'
|
37
|
+
task :destroy do
|
38
|
+
run_task('destroy')
|
39
|
+
end
|
40
|
+
|
41
|
+
desc 'Cleans up the project (after destroying infrastructure)'
|
42
|
+
task :clean do
|
43
|
+
run_task('clean')
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -1,2 +1,2 @@
|
|
1
|
-
require 'tfmodtest/module_helper'
|
2
|
-
TFModTest::ModuleHelper.install_tasks
|
1
|
+
require 'tfmodtest/module_helper'
|
2
|
+
TFModTest::ModuleHelper.install_tasks
|
@@ -1,56 +1,56 @@
|
|
1
|
-
require 'TerraformDevKit'
|
2
|
-
|
3
|
-
module TFModTest
|
4
|
-
TDK = TerraformDevKit
|
5
|
-
|
6
|
-
class ModuleTest
|
7
|
-
def initialize(module_name)
|
8
|
-
@module_name = module_name
|
9
|
-
end
|
10
|
-
|
11
|
-
def run_task(task_name)
|
12
|
-
puts("=== Running task #{task_name} for module #{@module_name} ===")
|
13
|
-
run_task_in_directory(task_name, module_path)
|
14
|
-
end
|
15
|
-
|
16
|
-
def module_path
|
17
|
-
File.join('test', @module_name)
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def run_task_in_directory(task_name, dir)
|
23
|
-
Dir.chdir(dir) do
|
24
|
-
load 'Rakefile'
|
25
|
-
begin
|
26
|
-
Rake::Task["#{@module_name}:#{task_name}"].invoke(DEFAULT_PREFIX)
|
27
|
-
rescue RuntimeError => e
|
28
|
-
puts e.message
|
29
|
-
puts e.backtrace.join("\n")
|
30
|
-
Rake::Task["#{@module_name}:clean"].invoke(DEFAULT_PREFIX)
|
31
|
-
raise "Error testing module #{@module_name}"
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
class ModuleTestRepository
|
38
|
-
def self.each
|
39
|
-
modules_path = Rake::FileList.new('test/*')
|
40
|
-
modules_path.each do |path|
|
41
|
-
module_name = File.basename(path)
|
42
|
-
yield ModuleTest.new(module_name) unless excluded?(module_name)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
private_class_method
|
47
|
-
def self.excluded?(module_name)
|
48
|
-
excluded_modules.include?(module_name)
|
49
|
-
end
|
50
|
-
|
51
|
-
private_class_method
|
52
|
-
def self.excluded_modules
|
53
|
-
ENV.fetch('TM_EXCLUDE_MODULES', '').split(',')
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
1
|
+
require 'TerraformDevKit'
|
2
|
+
|
3
|
+
module TFModTest
|
4
|
+
TDK = TerraformDevKit
|
5
|
+
|
6
|
+
class ModuleTest
|
7
|
+
def initialize(module_name)
|
8
|
+
@module_name = module_name
|
9
|
+
end
|
10
|
+
|
11
|
+
def run_task(task_name)
|
12
|
+
puts("=== Running task #{task_name} for module #{@module_name} ===")
|
13
|
+
run_task_in_directory(task_name, module_path)
|
14
|
+
end
|
15
|
+
|
16
|
+
def module_path
|
17
|
+
File.join('test', @module_name)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def run_task_in_directory(task_name, dir)
|
23
|
+
Dir.chdir(dir) do
|
24
|
+
load 'Rakefile'
|
25
|
+
begin
|
26
|
+
Rake::Task["#{@module_name}:#{task_name}"].invoke(DEFAULT_PREFIX)
|
27
|
+
rescue RuntimeError => e
|
28
|
+
puts e.message
|
29
|
+
puts e.backtrace.join("\n")
|
30
|
+
Rake::Task["#{@module_name}:clean"].invoke(DEFAULT_PREFIX)
|
31
|
+
raise "Error testing module #{@module_name}"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
class ModuleTestRepository
|
38
|
+
def self.each
|
39
|
+
modules_path = Rake::FileList.new('test/*')
|
40
|
+
modules_path.each do |path|
|
41
|
+
module_name = File.basename(path)
|
42
|
+
yield ModuleTest.new(module_name) unless excluded?(module_name)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
private_class_method
|
47
|
+
def self.excluded?(module_name)
|
48
|
+
excluded_modules.include?(module_name)
|
49
|
+
end
|
50
|
+
|
51
|
+
private_class_method
|
52
|
+
def self.excluded_modules
|
53
|
+
ENV.fetch('TM_EXCLUDE_MODULES', '').split(',')
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/lib/tfmodtest/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module TFModTest
|
2
|
-
VERSION = '0.
|
3
|
-
end
|
1
|
+
module TFModTest
|
2
|
+
VERSION = '0.1.0'.freeze
|
3
|
+
end
|
data/tfmodtest.gemspec
CHANGED
@@ -1,28 +1,28 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
lib = File.expand_path('../lib', __FILE__)
|
4
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
-
require 'tfmodtest/version'
|
6
|
-
|
7
|
-
Gem::Specification.new do |spec|
|
8
|
-
spec.name = 'tfmodtest'
|
9
|
-
spec.version = TFModTest::VERSION
|
10
|
-
spec.authors = ['Victor Jimenez', 'Daniel Baker']
|
11
|
-
spec.email = ['vjimenez@vistaprint.com', 'dbaker@vistaprint.com']
|
12
|
-
|
13
|
-
spec.summary = 'Set of scripts to ease testing of Terraform modules.'
|
14
|
-
spec.homepage = 'https://github.com/vistaprint/tfmodtest'
|
15
|
-
spec.license = 'Apache-2.0'
|
16
|
-
|
17
|
-
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
-
f.match(%r{^(test|spec|features)/})
|
19
|
-
end
|
20
|
-
spec.bindir = 'exe'
|
21
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
-
spec.require_paths = ['lib']
|
23
|
-
|
24
|
-
spec.add_development_dependency 'bundler'
|
25
|
-
spec.add_development_dependency 'rake'
|
26
|
-
|
27
|
-
spec.add_runtime_dependency 'TerraformDevKit', '
|
28
|
-
end
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'tfmodtest/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'tfmodtest'
|
9
|
+
spec.version = TFModTest::VERSION
|
10
|
+
spec.authors = ['Victor Jimenez', 'Daniel Baker']
|
11
|
+
spec.email = ['vjimenez@vistaprint.com', 'dbaker@vistaprint.com']
|
12
|
+
|
13
|
+
spec.summary = 'Set of scripts to ease testing of Terraform modules.'
|
14
|
+
spec.homepage = 'https://github.com/vistaprint/tfmodtest'
|
15
|
+
spec.license = 'Apache-2.0'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.bindir = 'exe'
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ['lib']
|
23
|
+
|
24
|
+
spec.add_development_dependency 'bundler'
|
25
|
+
spec.add_development_dependency 'rake'
|
26
|
+
|
27
|
+
spec.add_runtime_dependency 'TerraformDevKit', '~> 0.4'
|
28
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tfmodtest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Jimenez
|
@@ -9,56 +9,50 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2020-03-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - "
|
18
|
+
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '
|
20
|
+
version: '0'
|
21
21
|
type: :development
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- - "
|
25
|
+
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: '
|
27
|
+
version: '0'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: rake
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- - "
|
32
|
+
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '
|
34
|
+
version: '0'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- - "
|
39
|
+
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: '
|
41
|
+
version: '0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: TerraformDevKit
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- - "
|
47
|
-
- !ruby/object:Gem::Version
|
48
|
-
version: 0.2.6
|
49
|
-
- - "<"
|
46
|
+
- - "~>"
|
50
47
|
- !ruby/object:Gem::Version
|
51
|
-
version: 0.
|
48
|
+
version: '0.4'
|
52
49
|
type: :runtime
|
53
50
|
prerelease: false
|
54
51
|
version_requirements: !ruby/object:Gem::Requirement
|
55
52
|
requirements:
|
56
|
-
- - "
|
57
|
-
- !ruby/object:Gem::Version
|
58
|
-
version: 0.2.6
|
59
|
-
- - "<"
|
53
|
+
- - "~>"
|
60
54
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
55
|
+
version: '0.4'
|
62
56
|
description:
|
63
57
|
email:
|
64
58
|
- vjimenez@vistaprint.com
|
@@ -94,12 +88,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
94
88
|
version: '0'
|
95
89
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
90
|
requirements:
|
97
|
-
- - "
|
91
|
+
- - ">="
|
98
92
|
- !ruby/object:Gem::Version
|
99
|
-
version:
|
93
|
+
version: '0'
|
100
94
|
requirements: []
|
101
|
-
|
102
|
-
rubygems_version: 2.6.13
|
95
|
+
rubygems_version: 3.1.2
|
103
96
|
signing_key:
|
104
97
|
specification_version: 4
|
105
98
|
summary: Set of scripts to ease testing of Terraform modules.
|