All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonTest.aws.sdk.kotlin.runtime.region.ProfileRegionProviderTest.kt Maven / Gradle / Ivy

/*
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * SPDX-License-Identifier: Apache-2.0
 */

package aws.sdk.kotlin.runtime.region

import aws.sdk.kotlin.runtime.config.profile.AwsConfigValue
import aws.sdk.kotlin.runtime.config.profile.AwsProfile
import aws.smithy.kotlin.runtime.util.asyncLazy
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runTest
import kotlin.test.Test
import kotlin.test.assertEquals

@OptIn(ExperimentalCoroutinesApi::class)
class ProfileRegionProviderTest {
    @Test
    fun testSuccessDefaultProfile() = runTest {
        val profile = AwsProfile(
            "default",
            mapOf(
                "region" to AwsConfigValue.String("us-east-2"),
            ),
        )

        val lazyProfile = asyncLazy { profile }
        val provider = ProfileRegionProvider(lazyProfile)
        assertEquals("us-east-2", provider.getRegion())
    }

    @Test
    fun testNoRegion() = runTest {
        val profile = AwsProfile(
            "default",
            mapOf(
                "not-region" to AwsConfigValue.String("us-east-2"),
            ),
        )

        val lazyProfile = asyncLazy { profile }
        val provider = ProfileRegionProvider(lazyProfile)
        assertEquals(null, provider.getRegion())
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy