@@ -274,6 +274,62 @@ describe('configureIndex', () => {
274274 expect ( IOA . describeIndex ) . toHaveBeenCalled ( ) ;
275275 expect ( IOA . configureIndex ) . not . toHaveBeenCalled ( ) ;
276276 } ) ;
277+
278+ test ( 'skips describeIndex when only non-spec params are updated' , async ( ) => {
279+ const fakeConfigure : (
280+ req : ConfigureIndexOperationRequest ,
281+ ) => Promise < IndexModel > = jest . fn ( ) . mockResolvedValue ( podIndexModel ) ;
282+ const IOA = {
283+ describeIndex : jest . fn ( ) ,
284+ configureIndex : fakeConfigure ,
285+ } as unknown as ManageIndexesApi ;
286+
287+ const returned = await configureIndex ( IOA ) ( {
288+ name : 'pod-index' ,
289+ deletionProtection : 'enabled' ,
290+ tags : { env : 'prod' } ,
291+ } ) ;
292+
293+ expect ( returned ) . toBe ( podIndexModel ) ;
294+ // describeIndex must NOT be called — no spec params were supplied
295+ expect ( IOA . describeIndex ) . not . toHaveBeenCalled ( ) ;
296+ expect ( IOA . configureIndex ) . toHaveBeenCalledWith ( {
297+ indexName : 'pod-index' ,
298+ configureIndexRequest : {
299+ spec : undefined ,
300+ deletionProtection : 'enabled' ,
301+ tags : { env : 'prod' } ,
302+ embed : undefined ,
303+ } ,
304+ xPineconeApiVersion : X_PINECONE_API_VERSION ,
305+ } ) ;
306+ } ) ;
307+
308+ test ( 'throws error when spec type cannot be determined and spec params are supplied' , async ( ) => {
309+ // Return an IndexModel whose spec has no recognisable type
310+ const unknownSpecModel = {
311+ ...podIndexModel ,
312+ spec : { } ,
313+ } as unknown as IndexModel ;
314+ const fakeDescribe : ( req : DescribeIndexRequest ) => Promise < IndexModel > =
315+ jest . fn ( ) . mockResolvedValue ( unknownSpecModel ) ;
316+ const IOA = {
317+ describeIndex : fakeDescribe ,
318+ configureIndex : jest . fn ( ) ,
319+ } as unknown as ManageIndexesApi ;
320+
321+ await expect (
322+ configureIndex ( IOA ) ( {
323+ name : 'pod-index' ,
324+ podReplicas : 2 ,
325+ } ) ,
326+ ) . rejects . toThrow (
327+ 'Could not determine the index spec type. Verify the index exists and try again.' ,
328+ ) ;
329+
330+ expect ( IOA . describeIndex ) . toHaveBeenCalled ( ) ;
331+ expect ( IOA . configureIndex ) . not . toHaveBeenCalled ( ) ;
332+ } ) ;
277333} ) ;
278334
279335describe ( 'getIndexSpecType' , ( ) => {
0 commit comments