Skip to content

Commit f438e16

Browse files
author
Changjian Wang
committed
Fix environment variable check to skip tests when either variable is missing
- Changed logic from AND to OR: skip test if endpoint OR key is missing - Both environment variables are required for integration tests to run - This ensures tests are skipped in Azure DevOps pipeline without proper credentials
1 parent a944564 commit f438e16

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

sdk/contentunderstanding/azure-ai-contentunderstanding/src/test/java/com/azure/ai/contentunderstanding/generated/ContentUnderstandingClientTestBase.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,16 @@ class ContentUnderstandingClientTestBase extends TestProxyTestBase {
2727
* Utility method to check if required environment variables are available.
2828
* If they are not available, the test will be skipped.
2929
* This is useful for integration tests that require real Azure credentials.
30+
*
31+
* Both CONTENTUNDERSTANDING_ENDPOINT and AZURE_CONTENT_UNDERSTANDING_KEY must be set
32+
* for the test to run. If either is missing, the test is skipped.
3033
*/
3134
protected static void skipIfRequiredEnvironmentVariablesNotSet() {
3235
String endpoint = Configuration.getGlobalConfiguration().get("CONTENTUNDERSTANDING_ENDPOINT");
3336
String key = System.getenv("AZURE_CONTENT_UNDERSTANDING_KEY");
3437

35-
if ((endpoint == null || endpoint.trim().isEmpty()) && (key == null || key.trim().isEmpty())) {
38+
// Skip test if either required environment variable is missing or empty
39+
if ((endpoint == null || endpoint.trim().isEmpty()) || (key == null || key.trim().isEmpty())) {
3640
throw new TestAbortedException(
3741
"Required environment variables CONTENTUNDERSTANDING_ENDPOINT or AZURE_CONTENT_UNDERSTANDING_KEY are not set. Skipping test.");
3842
}

0 commit comments

Comments
 (0)