Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Johnson committed Jan 17, 2025
1 parent bf4af57 commit cee984a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ public static class KnownQueryParameterNames
public const string Container = "_container";

/// <summary>
/// Originally for CosmosDB workloads to hint that this request should run with a max parallel setting.
/// This settings is currently set by:
/// x-ms-query-latency-over-efficiency - Gen1 and Gen2
/// x-conditionalquery-processing-logic - Gen1 only
/// In Gen1 it is used to hint that the request should run with a max parallel setting.
/// In Gen2 it is used to tell the system to optimize for latency over efficiency by running two queries in parallel (with and without query caching).
/// </summary>
public const string OptimizeConcurrency = "_optimizeConcurrency";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ public sealed class QueryLatencyOverEfficiencyFilterAttributeTests
private readonly IFhirRuntimeConfiguration _azureApiForFhirConfiguration = new AzureApiForFhirRuntimeConfiguration();
private readonly IFhirRuntimeConfiguration _azureHealthDataServicesFhirConfiguration = new AzureHealthDataServicesRuntimeConfiguration();

[Fact]
public void GivenAValidHttpContextForAzureApiForFhir_WhenItContainsALatencyOverEfficiencyFlag_ThenFhirContextIsDecorated()
[Theory]
[InlineData(true)]
[InlineData(false)]
public void GivenAValidHttpContextForAzureApiForFhir_WhenItContainsALatencyOverEfficiencyFlag_ThenFhirContextIsDecorated(bool azureApiForFhir)
{
var httpRequest = GetFakeHttpContext(isLatencyOverEfficiencyEnabled: true);

var filter = new QueryLatencyOverEfficiencyFilterAttribute(httpRequest.RequestContext, _azureApiForFhirConfiguration);
var filter = new QueryLatencyOverEfficiencyFilterAttribute(httpRequest.RequestContext, azureApiForFhir ? _azureApiForFhirConfiguration : _azureHealthDataServicesFhirConfiguration);
filter.OnActionExecuting(httpRequest.ActionContext);

var fhirContextPropertyBag = httpRequest.RequestContext.RequestContext.Properties;
Expand All @@ -43,27 +45,14 @@ public void GivenAValidHttpContextForAzureApiForFhir_WhenItContainsALatencyOverE
Assert.Equal(true, fhirContextPropertyBag[KnownQueryParameterNames.OptimizeConcurrency]);
}

[Fact]
public void GivenAValidHttpContextForAzureHealthDataService_WhenItContainsALatencyOverEfficiencyFlag_ThenFhirContextIsNotDecorated()
{
// The latency-over-efficiency flag is only applicable to Azure API for FHIR.

var httpRequest = GetFakeHttpContext(isLatencyOverEfficiencyEnabled: true);

var filter = new QueryLatencyOverEfficiencyFilterAttribute(httpRequest.RequestContext, _azureHealthDataServicesFhirConfiguration);
filter.OnActionExecuting(httpRequest.ActionContext);

var fhirContextPropertyBag = httpRequest.RequestContext.RequestContext.Properties;

Assert.False(fhirContextPropertyBag.ContainsKey(KnownQueryParameterNames.OptimizeConcurrency));
}

[Fact]
public void GivenAValidHttpContext_WhenItDoesNotContainALatencyOverEfficiencyFlag_ThenFhirContextIsClean()
[Theory]
[InlineData(true)]
[InlineData(false)]
public void GivenAValidHttpContext_WhenItDoesNotContainALatencyOverEfficiencyFlag_ThenFhirContextIsClean(bool azureApiForFhir)
{
var httpRequest = GetFakeHttpContext(isLatencyOverEfficiencyEnabled: false);

var filter = new QueryLatencyOverEfficiencyFilterAttribute(httpRequest.RequestContext, _azureApiForFhirConfiguration);
var filter = new QueryLatencyOverEfficiencyFilterAttribute(httpRequest.RequestContext, azureApiForFhir ? _azureApiForFhirConfiguration : _azureHealthDataServicesFhirConfiguration);
filter.OnActionExecuting(httpRequest.ActionContext);

var fhirContextPropertyBag = httpRequest.RequestContext.RequestContext.Properties;
Expand Down

0 comments on commit cee984a

Please sign in to comment.