@@ -5,7 +5,8 @@ import * as chai from "chai";
55import * as chaiAsPromised from "chai-as-promised" ;
66chai . use ( chaiAsPromised ) ;
77const expect = chai . expect ;
8- import { MAX_TIME_OUT , createMockedConnectionString , createMockedKeyValue , createMockedTokenCredential , mockAppConfigurationClientListConfigurationSettings , restoreMocks , sleepInMs } from "./utils/testHelper.js" ;
8+ import { MAX_TIME_OUT , createMockedConnectionString , createMockedKeyValue , createMockedTokenCredential , mockAppConfigurationClientListConfigurationSettings , restoreMocks , sinon , sleepInMs } from "./utils/testHelper.js" ;
9+ import { ConfigurationClientManager } from "../src/ConfigurationClientManager.js" ;
910import { load } from "./exportedApi.js" ;
1011
1112class HttpRequestHeadersPolicy {
@@ -75,6 +76,19 @@ describe("request tracing", function () {
7576 expect ( correlationContext . includes ( "UsesKeyVault" ) ) . eq ( true ) ;
7677 } ) ;
7778
79+ it ( "should have replica count in correlation-context header" , async ( ) => {
80+ const replicaCount = 2 ;
81+ sinon . stub ( ConfigurationClientManager . prototype , "getReplicaCount" ) . returns ( replicaCount ) ;
82+ try {
83+ await load ( createMockedConnectionString ( fakeEndpoint ) , { clientOptions } ) ;
84+ } catch ( e ) { /* empty */ }
85+ expect ( headerPolicy . headers ) . not . undefined ;
86+ const correlationContext = headerPolicy . headers . get ( "Correlation-Context" ) ;
87+ expect ( correlationContext ) . not . undefined ;
88+ expect ( correlationContext . includes ( `ReplicaCount=${ replicaCount } ` ) ) . eq ( true ) ;
89+ sinon . restore ( ) ;
90+ } ) ;
91+
7892 it ( "should detect env in correlation-context header" , async ( ) => {
7993 process . env . NODE_ENV = "development" ;
8094 try {
0 commit comments