Skip to content

Commit 0e8e2a0

Browse files
authored
Merge pull request #1005 from block/myron/fix-warehouse-spec-failure
Fix flaky test due to AWS SDK caching ~/.aws/config region
2 parents 014c1bb + 2c902fb commit 0e8e2a0

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

elasticgraph-warehouse_lambda/spec/unit/elastic_graph/warehouse_lambda_spec.rb

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,17 @@ module ElasticGraph
7070
end
7171

7272
it "raises an error if `aws_region` is not configured and `AWS_REGION` env var is not set" do
73-
warehouse_lambda = build_warehouse_lambda(aws_region: nil)
73+
# Clear all AWS region sources to ensure MissingRegionError is raised.
74+
# We must also reset `Aws.shared_config` since it caches parsed config from ~/.aws/config.
75+
with_env("AWS_REGION" => nil, "AWS_DEFAULT_REGION" => nil, "AWS_CONFIG_FILE" => "/nonexistent") do
76+
::Aws.instance_variable_set(:@shared_config, nil)
7477

75-
expect {
76-
warehouse_lambda.s3_client
77-
}.to raise_error ::Aws::Errors::MissingRegionError
78+
warehouse_lambda = build_warehouse_lambda(aws_region: nil)
79+
80+
expect {
81+
warehouse_lambda.s3_client
82+
}.to raise_error ::Aws::Errors::MissingRegionError
83+
end
7884
end
7985
end
8086
end

0 commit comments

Comments
 (0)