@@ -78,6 +78,23 @@ vi.mock("../plugins/provider-runtime.js", () => ({
7878 resolveProviderSyntheticAuthWithPlugin,
7979} ) ) ;
8080
81+ function expectAuthResult (
82+ value : ReturnType < ReturnType < typeof createProviderAuthResolver > > ,
83+ expected : {
84+ apiKey ?: string ;
85+ mode : string ;
86+ source : string ;
87+ profileId ?: string ;
88+ } ,
89+ ) {
90+ expect ( value . apiKey ) . toBe ( expected . apiKey ) ;
91+ expect ( value . mode ) . toBe ( expected . mode ) ;
92+ expect ( value . source ) . toBe ( expected . source ) ;
93+ if ( "profileId" in expected ) {
94+ expect ( value . profileId ) . toBe ( expected . profileId ) ;
95+ }
96+ }
97+
8198describe ( "provider auth aliases" , ( ) => {
8299 beforeEach ( async ( ) => {
83100 vi . resetModules ( ) ;
@@ -95,12 +112,12 @@ describe("provider auth aliases", () => {
95112 { version : 1 , profiles : { } } ,
96113 ) ;
97114
98- expect ( resolveAuth ( "fixture-provider" ) ) . toMatchObject ( {
115+ expectAuthResult ( resolveAuth ( "fixture-provider" ) , {
99116 apiKey : "FIXTURE_PROVIDER_API_KEY" ,
100117 mode : "api_key" ,
101118 source : "env" ,
102119 } ) ;
103- expect ( resolveAuth ( "fixture-provider-plan" ) ) . toMatchObject ( {
120+ expectAuthResult ( resolveAuth ( "fixture-provider-plan" ) , {
104121 apiKey : "FIXTURE_PROVIDER_API_KEY" ,
105122 mode : "api_key" ,
106123 source : "env" ,
@@ -119,13 +136,13 @@ describe("provider auth aliases", () => {
119136 } ,
120137 } ) ;
121138
122- expect ( resolveAuth ( "fixture-provider" ) ) . toMatchObject ( {
139+ expectAuthResult ( resolveAuth ( "fixture-provider" ) , {
123140 apiKey : "FIXTURE_PROVIDER_API_KEY" ,
124141 mode : "api_key" ,
125142 source : "profile" ,
126143 profileId : "fixture-provider:default" ,
127144 } ) ;
128- expect ( resolveAuth ( "fixture-provider-plan" ) ) . toMatchObject ( {
145+ expectAuthResult ( resolveAuth ( "fixture-provider-plan" ) , {
129146 apiKey : "FIXTURE_PROVIDER_API_KEY" ,
130147 mode : "api_key" ,
131148 source : "profile" ,
@@ -169,12 +186,12 @@ describe("provider auth aliases", () => {
169186 { } ,
170187 ) ;
171188
172- expect ( resolveAuth ( "openai" ) ) . toMatchObject ( {
189+ expectAuthResult ( resolveAuth ( "openai" ) , {
173190 apiKey : "OPENAI_API_KEY" ,
174191 mode : "api_key" ,
175192 source : "env" ,
176193 } ) ;
177- expect ( resolveAuth ( "evil-openai" ) ) . toMatchObject ( {
194+ expectAuthResult ( resolveAuth ( "evil-openai" ) , {
178195 apiKey : undefined ,
179196 mode : "none" ,
180197 source : "none" ,
@@ -225,7 +242,7 @@ describe("provider auth aliases", () => {
225242 } ,
226243 ) ;
227244
228- expect ( resolveAuth ( "openai-compatible" ) ) . toMatchObject ( {
245+ expectAuthResult ( resolveAuth ( "openai-compatible" ) , {
229246 apiKey : "OPENAI_API_KEY" ,
230247 mode : "api_key" ,
231248 source : "env" ,
0 commit comments