aboutsummaryrefslogtreecommitdiff
path: root/test/models
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2018-04-03 07:52:00 +0100
committerChristopher Baines <mail@cbaines.net>2018-04-03 21:58:55 +0100
commit9e622112a80f493eab53420d7dafedb9dd10a612 (patch)
tree6a21d19f6ff7ae72db8510f8e0ae813bb8a49045 /test/models
parenta29946a593988003cbd4637293c5b4cc1aee7eaa (diff)
downloadgovuk-mini-environment-admin-9e622112a80f493eab53420d7dafedb9dd10a612.tar
govuk-mini-environment-admin-9e622112a80f493eab53420d7dafedb9dd10a612.tar.gz
Improve the test suite
Add some tests, and setup the helpers. For some reason, directly running the test files requires the ugly `ENV['RAILS_ENV'] = 'test'` line at the top of the test_helper.rb file.
Diffstat (limited to 'test/models')
-rw-r--r--test/models/backends/terraform_aws_test.rb45
-rw-r--r--test/models/backends/terraform_libvirt_test.rb45
2 files changed, 84 insertions, 6 deletions
diff --git a/test/models/backends/terraform_aws_test.rb b/test/models/backends/terraform_aws_test.rb
index 78cd8de..2337bda 100644
--- a/test/models/backends/terraform_aws_test.rb
+++ b/test/models/backends/terraform_aws_test.rb
@@ -1,7 +1,46 @@
require 'test_helper'
class Backends::TerraformAwsTest < ActiveSupport::TestCase
- # test "the truth" do
- # assert true
- # end
+ setup do
+ @backend = Backends::TerraformAws.new
+ @mini_environment = MiniEnvironment.new(
+ id: 1,
+ name: 'Test Mini Environment',
+ backend_data: {
+ 'build_output': '/gnu/store/testbuildoutput',
+ }
+ )
+ end
+
+ test "type_and_id" do
+ @backend.type_and_id
+ end
+
+ test "build" do
+ GovukGuix::BuildJob.expects(:enqueue)
+
+ @backend.build(@mini_environment)
+ end
+
+ test "start" do
+ RubyTerraform.stubs(:init)
+ RubyTerraform.expects(:apply)
+
+ @backend.start(@mini_environment)
+ end
+
+ test "destroy" do
+ RubyTerraform.stubs(:init)
+ RubyTerraform.expects(:destroy)
+
+ @backend.destroy(@mini_environment)
+ end
+
+ test "signon_url" do
+ @backend.signon_url(@mini_environment)
+ end
+
+ test "terraform_variables" do
+ @backend.terraform_variables(@mini_environment)
+ end
end
diff --git a/test/models/backends/terraform_libvirt_test.rb b/test/models/backends/terraform_libvirt_test.rb
index b7d3c35..e509b03 100644
--- a/test/models/backends/terraform_libvirt_test.rb
+++ b/test/models/backends/terraform_libvirt_test.rb
@@ -1,7 +1,46 @@
require 'test_helper'
class Backends::TerraformLibvirtTest < ActiveSupport::TestCase
- # test "the truth" do
- # assert true
- # end
+ setup do
+ @backend = Backends::TerraformLibvirt.new
+ @mini_environment = MiniEnvironment.new(
+ id: 1,
+ name: 'Test Mini Environment',
+ backend_data: {
+ 'build_output': '/gnu/store/testbuildoutput',
+ }
+ )
+ end
+
+ test "type_and_id" do
+ @backend.type_and_id
+ end
+
+ test "build" do
+ GovukGuix::BuildJob.expects(:enqueue)
+
+ @backend.build(@mini_environment)
+ end
+
+ test "start" do
+ RubyTerraform.stubs(:init)
+ RubyTerraform.expects(:apply)
+
+ @backend.start(@mini_environment)
+ end
+
+ test "destroy" do
+ RubyTerraform.stubs(:init)
+ RubyTerraform.expects(:destroy)
+
+ @backend.destroy(@mini_environment)
+ end
+
+ test "signon_url" do
+ @backend.signon_url(@mini_environment)
+ end
+
+ test "terraform_variables" do
+ @backend.terraform_variables(@mini_environment)
+ end
end