Skip to content

Commit

Permalink
[DocumentIntelligence] Enabling live testing (#43455)
Browse files Browse the repository at this point in the history
  • Loading branch information
kinelski committed Apr 29, 2024
1 parent 151e662 commit f3f1c6a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
using Azure.Core.TestFramework;

namespace Azure.AI.DocumentIntelligence.Tests
Expand Down Expand Up @@ -51,5 +52,23 @@ public static BinaryData CreateBinaryData(string filename)

return BinaryData.FromBytes(bytes);
}

protected override async ValueTask<bool> IsEnvironmentReadyAsync()
{
var endpoint = new Uri(Endpoint);
var keyCredential = new AzureKeyCredential(ApiKey);
var keyCredentialClient = new DocumentIntelligenceAdministrationClient(endpoint, keyCredential);

try
{
await keyCredentialClient.GetResourceInfoAsync();
}
catch (RequestFailedException e) when (e.Status == 401)
{
return false;
}

return true;
}
}
}
4 changes: 4 additions & 0 deletions sdk/documentintelligence/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ extends:
template: ../../eng/pipelines/templates/stages/archetype-sdk-tests.yml
parameters:
ServiceDirectory: documentintelligence
CloudConfig:
Public:
SubscriptionConfiguration: $(sub-config-azure-cloud-test-resources)
Location: 'eastus'
SupportedClouds: 'Public'

0 comments on commit f3f1c6a

Please sign in to comment.