<commit_before>require 'test_helper'
require 'json'

class TestLambdaPermission < Minitest::Test
  def setup
    @template = ::Convection.template do
      description 'Lambda Permission Test Template'

      lambda_permission 'LambdaInvokePermission' do
        action 'lambda:InvokeFunction'
        function_name get_att('MyLambdaFunction', 'Arn')
        principal 's3.amazonaws.com'
        source_account fn_ref('AWS::AccountId')
      end
    end
  end

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

  def test_lambda_permission
    # Expected JSON:
    json = from_json['Resources']['LambdaInvokePermission']
    properties = json['Properties']

    assert_equal properties['Action'], 'lambda:InvokeFunction'
    assert_equal properties['FunctionName'], 'Fn::GetAtt' => ['MyLambdaFunction', 'Arn']
    assert_equal properties['SourceAccount'], 'Ref' => 'AWS::AccountId'
  end
end<commit_msg>Resolve style violation in array declaration<commit_after>require 'test_helper'
require 'json'

class TestLambdaPermission < Minitest::Test
  def setup
    @template = ::Convection.template do
      description 'Lambda Permission Test Template'

      lambda_permission 'LambdaInvokePermission' do
        action 'lambda:InvokeFunction'
        function_name get_att('MyLambdaFunction', 'Arn')
        principal 's3.amazonaws.com'
        source_account fn_ref('AWS::AccountId')
      end
    end
  end

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

  def test_lambda_permission
    # Expected JSON:
    json = from_json['Resources']['LambdaInvokePermission']
    properties = json['Properties']

    assert_equal properties['Action'], 'lambda:InvokeFunction'
    assert_equal properties['FunctionName'], 'Fn::GetAtt' => %w(MyLambdaFunction Arn)
    assert_equal properties['SourceAccount'], 'Ref' => 'AWS::AccountId'
  end
end
{'fraction_non_alphanumeric': 0.10497835497835498, 'fraction_numerical': 0.0010822510822510823, 'mean_word_length': 4.282857142857143, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3507189', 'n_tokens_mistral': 521, 'n_tokens_neox': 512, 'n_words': 120}