|
| 1 | +// Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"). You may |
| 4 | +// not use this file except in compliance with the License. A copy of the |
| 5 | +// License is located at |
| 6 | +// |
| 7 | +// http://aws.amazon.com/apache2.0/ |
| 8 | +// |
| 9 | +// or in the "license" file accompanying this file. This file is distributed |
| 10 | +// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either |
| 11 | +// express or implied. See the License for the specific language governing |
| 12 | +// permissions and limitations under the License. |
| 13 | + |
| 14 | +package cloudwatchlogs |
| 15 | + |
| 16 | +import ( |
| 17 | + "testing" |
| 18 | + |
| 19 | + "github.com/aws/amazon-ecs-cli/ecs-cli/modules/config" |
| 20 | + "github.com/aws/aws-sdk-go/aws" |
| 21 | + "github.com/aws/aws-sdk-go/aws/session" |
| 22 | + "github.com/stretchr/testify/assert" |
| 23 | +) |
| 24 | + |
| 25 | +func TestNewCloudWatchLogsClientLeavesRegionIntact(t *testing.T) { |
| 26 | + // Test that it doesn't mess up command config session and re-set the region |
| 27 | + correctRegion := "eu-west-1" |
| 28 | + sess, err := session.NewSession(&aws.Config{ |
| 29 | + Region: aws.String(correctRegion), |
| 30 | + }) |
| 31 | + assert.NoError(t, err) |
| 32 | + params := &config.CommandConfig{ |
| 33 | + Session: sess, |
| 34 | + } |
| 35 | + |
| 36 | + NewCloudWatchLogsClient(params, "us-east-2") |
| 37 | + |
| 38 | + assert.Equal(t, correctRegion, aws.StringValue(params.Session.Config.Region), "Expected configured region to remain unchanged after call to NewCloudWatchLogsClient()") |
| 39 | + |
| 40 | +} |
0 commit comments