|
22 | 22 | import java.util.stream.Stream; |
23 | 23 |
|
24 | 24 | import org.junit.jupiter.api.Test; |
| 25 | +import org.junit.jupiter.params.ParameterizedTest; |
| 26 | +import org.junit.jupiter.params.provider.ValueSource; |
25 | 27 |
|
26 | 28 | import org.springframework.boot.context.properties.bind.Binder; |
27 | 29 | import org.springframework.boot.context.properties.source.MockConfigurationPropertySource; |
@@ -205,6 +207,28 @@ void getActiveWhenHasMissingWebsiteSkuShouldNotReturnAzureAppService() { |
205 | 207 | assertThat(platform).isNull(); |
206 | 208 | } |
207 | 209 |
|
| 210 | + @Test |
| 211 | + void getActiveWhenHasAllAwsEnvVariablesShouldReturnAws() { |
| 212 | + Map<String, Object> envVars = new HashMap<>(); |
| 213 | + envVars.put("AWS_DEFAULT_REGION", "eu-west-1"); |
| 214 | + envVars.put("AWS_EXECUTION_ENV", "AWS_ECS_FARGATE"); |
| 215 | + Environment environment = getEnvironmentWithEnvVariables(envVars); |
| 216 | + CloudPlatform platform = CloudPlatform.getActive(environment); |
| 217 | + assertThat(platform).isNotNull().isEqualTo(CloudPlatform.AWS); |
| 218 | + assertThat(platform.isActive(environment)).isTrue(); |
| 219 | + } |
| 220 | + |
| 221 | + @ParameterizedTest |
| 222 | + @ValueSource(strings = { "AWS_DEFAULT_REGION", "AWS_EXECUTION_ENV" }) |
| 223 | + void getActiveWhenHasMissingAwsVariableShouldNotReturnAws(String missingEnvVar) { |
| 224 | + Map<String, Object> envVars = new HashMap<>(); |
| 225 | + envVars.compute("AWS_DEFAULT_REGION", (k, v) -> k.equals(missingEnvVar) ? null : "eu-west-1"); |
| 226 | + envVars.compute("AWS_EXECUTION_ENV", (k, v) -> k.equals(missingEnvVar) ? null : "AWS_ECS_FARGATE"); |
| 227 | + Environment environment = getEnvironmentWithEnvVariables(envVars); |
| 228 | + CloudPlatform platform = CloudPlatform.getActive(environment); |
| 229 | + assertThat(platform).isNull(); |
| 230 | + } |
| 231 | + |
208 | 232 | @Test |
209 | 233 | void getActiveWhenHasEnforcedCloudPlatform() { |
210 | 234 | Environment environment = getEnvironmentWithEnvVariables( |
|
0 commit comments