<commit_before>require_relative '../../spec_helper'

module Aws
  module Plugins
    describe RegionalEndpoint do

      RegionalEndpointClient = ApiHelper.sample_service.const_get(:Client)

      let(:env) {{}}

      let(:client_class) { RegionalEndpointClient }

      before do
        stub_const("ENV", env)
      end

      describe 'region option' do

        it 'adds a :region configuration option' do
          expect(client_class.new(region: 'region').config.region).to eq('region')
        end

        it 'defaults to ENV["AWS_DEFAULT_REGION"]' do
          env['AWS_DEFAULT_REGION'] = 'env-region'
          expect(client_class.new.config.region).to eq('env-region')
        end

        it 'defaults to ENV["AWS_REGION"]' do
          env['AWS_REGION'] = 'env-fallback1'
          expect(client_class.new.config.region).to eq('env-fallback1')
        end

        it 'falls back to ENV["AMAZON_REGION"]' do
          env['AMAZON_REGION'] = 'region-fallback2'
          expect(client_class.new.config.region).to eq('region-fallback2')
        end

        it 'prefers AWS_DEFAULT_REGION to AWS_REGION or AMAZON_REGION' do
          env['AWS_REGION'] = 'aws-region'
          env['AMAZON_REGION'] = 'amazon-region'
          env['AWS_DEFAULT_REGION'] = 'aws-default-region'
          expect(client_class.new.config.region).to eq('aws-region')
        end

        it 'prefers AWS_REGION to AMAZON_REGION' do
          env['AWS_REGION'] = 'aws-region'
          env['AMAZON_REGION'] = 'amazon-region'
          expect(client_class.new.config.region).to eq('aws-region')
        end

        it 'can be set directly, overriding the ENV["AWS_REGION"]' do
          env['AWS_REGION'] = 'env-region'
          expect(client_class.new(region:'cfg').config.region).to eq('cfg')
        end

        it 'raises an argument error when not set' do
          client = Seahorse::Client::Base.define
          client.add_plugin(RegionalEndpoint)
          expect {
            client.new(endpoint:'http://foo.com')
          }.to raise_error(Errors::MissingRegionError)
        end

        it 'raises an argument error when set to nil' do
          client = Seahorse::Client::Base.define<commit_msg>Fix the wrong description in spec test (#1817)<commit_after>require_relative '../../spec_helper'

module Aws
  module Plugins
    describe RegionalEndpoint do

      RegionalEndpointClient = ApiHelper.sample_service.const_get(:Client)

      let(:env) {{}}

      let(:client_class) { RegionalEndpointClient }

      before do
        stub_const("ENV", env)
      end

      describe 'region option' do

        it 'adds a :region configuration option' do
          expect(client_class.new(region: 'region').config.region).to eq('region')
        end

        it 'defaults to ENV["AWS_DEFAULT_REGION"]' do
          env['AWS_DEFAULT_REGION'] = 'env-region'
          expect(client_class.new.config.region).to eq('env-region')
        end

        it 'defaults to ENV["AWS_REGION"]' do
          env['AWS_REGION'] = 'env-fallback1'
          expect(client_class.new.config.region).to eq('env-fallback1')
        end

        it 'falls back to ENV["AMAZON_REGION"]' do
          env['AMAZON_REGION'] = 'region-fallback2'
          expect(client_class.new.config.region).to eq('region-fallback2')
        end

        it 'prefers AWS_REGION to AMAZON_REGION or AWS_DEFAULT_REGION' do
          env['AWS_REGION'] = 'aws-region'
          env['AMAZON_REGION'] = 'amazon-region'
          env['AWS_DEFAULT_REGION'] = 'aws-default-region'
          expect(client_class.new.config.region).to eq('aws-region')
        end

        it 'prefers AWS_REGION to AMAZON_REGION' do
          env['AWS_REGION'] = 'aws-region'
          env['AMAZON_REGION'] = 'amazon-region'
          expect(client_class.new.config.region).to eq('aws-region')
        end

        it 'can be set directly, overriding the ENV["AWS_REGION"]' do
          env['AWS_REGION'] = 'env-region'
          expect(client_class.new(region:'cfg').config.region).to eq('cfg')
        end

        it 'raises an argument error when not set' do
          client = Seahorse::Client::Base.define
          client.add_plugin(RegionalEndpoint)
          expect {
            client.new(endpoint:'http://foo.com')
          }.to raise_error(Errors::MissingRegionError)
        end

        it 'raises an argument error when set to nil' do
          client = Seahorse::Client::Base.define
{'fraction_non_alphanumeric': 0.11888111888111888, 'fraction_numerical': 0.0027069704489059328, 'mean_word_length': 2.4694835680751175, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5009514', 'n_tokens_mistral': 1360, 'n_tokens_neox': 1353, 'n_words': 282}