Sha256: fde197c5e4a156c382cc96abc48085fce8072c0d236c96184bd48575b74b3a97

Contents?: true

Size: 1.23 KB

Versions: 16

Compression:

Stored size: 1.23 KB

Contents

require 'test_helper'
require 'json'
require 'pp'

class TestLambdas < Minitest::Test
  def setup
    @template = ::Convection.template do
      description 'Conditions Test Template'

      lambda_function 'TestLambda' do
        description 'Test description'
        handler 'index.handler'
        runtime 'nodejs'
        role 'arn:aws:x:y:z'

        code do
          s3_bucket 'testbucket'
          s3_key 'testkey'
        end

        vpc_config do
          security_groups %w(group1 group2)
          subnets %w(subnet1a subnet1b)
        end
      end
    end
  end

  def from_json
    JSON.parse(@template.to_json)
  end

  def test_lambda
    json = from_json['Resources']['TestLambda']['Properties']

    code = json['Code']
    assert_equal 'testbucket', code['S3Bucket']
    assert_equal 'testkey', code['S3Key']

    assert_equal 'arn:aws:x:y:z', json['Role']

    vpc = json['VpcConfig']
    refute vpc.nil?, 'VpcConfig not present in generated template'

    secgroups = vpc['SecurityGroupIds']
    assert secgroups.is_a?(Array), 'SecurityGroupIds is not an array'
    assert_equal 2, secgroups.size

    subnets = vpc['SubnetIds']
    assert subnets.is_a?(Array), 'SubnetIds is not an array'
    assert_equal 2, subnets.size
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
convection-0.2.32 test/convection/model/test_lambdas.rb
convection-0.2.31 test/convection/model/test_lambdas.rb
convection-0.2.30 test/convection/model/test_lambdas.rb
convection-0.2.29 test/convection/model/test_lambdas.rb
convection-0.2.28 test/convection/model/test_lambdas.rb
convection-0.2.27 test/convection/model/test_lambdas.rb
convection-0.2.26 test/convection/model/test_lambdas.rb
convection-0.2.25 test/convection/model/test_lambdas.rb
convection-0.2.24 test/convection/model/test_lambdas.rb
convection-0.2.23 test/convection/model/test_lambdas.rb
convection-0.2.22 test/convection/model/test_lambdas.rb
convection-0.2.21 test/convection/model/test_lambdas.rb
convection-0.2.20 test/convection/model/test_lambdas.rb
convection-0.2.19 test/convection/model/test_lambdas.rb
convection-0.2.18 test/convection/model/test_lambdas.rb
convection-0.2.17 test/convection/model/test_lambdas.rb