@@ -645,7 +645,7 @@ describe('resource-publisher', () => {
645645 expect ( client . putResource ) . not . toHaveBeenCalled ( ) ;
646646 } ) ;
647647
648- it ( 'should publish product subscription with empty displayName' , async ( ) => {
648+ it ( 'should skip auto-generated product subscription with empty displayName' , async ( ) => {
649649 const client = createMockClient ( ) ;
650650 const store = createMockStore ( ) ;
651651 const autoGeneratedId = generatedSubscriptionId ( 'a' ) ;
@@ -671,12 +671,12 @@ describe('resource-publisher', () => {
671671
672672 const result = await publishResource ( client , store , testContext , descriptor , testConfig ) ;
673673
674- expect ( result . status ) . toBe ( 'success ' ) ;
675- expect ( result . action ) . toBe ( 'put ' ) ;
676- expect ( client . putResource ) . toHaveBeenCalledTimes ( 1 ) ;
674+ expect ( result . status ) . toBe ( 'skipped ' ) ;
675+ expect ( result . action ) . toBe ( 'noop ' ) ;
676+ expect ( client . putResource ) . not . toHaveBeenCalled ( ) ;
677677 } ) ;
678678
679- it ( 'should publish product subscription when displayName is set' , async ( ) => {
679+ it ( 'should skip auto-generated product subscription when displayName is set' , async ( ) => {
680680 const client = createMockClient ( ) ;
681681 const store = createMockStore ( ) ;
682682 const autoGeneratedId = generatedSubscriptionId ( 'b' ) ;
@@ -701,6 +701,35 @@ describe('resource-publisher', () => {
701701
702702 const result = await publishResource ( client , store , testContext , descriptor , testConfig ) ;
703703
704+ expect ( result . status ) . toBe ( 'skipped' ) ;
705+ expect ( result . action ) . toBe ( 'noop' ) ;
706+ expect ( client . putResource ) . not . toHaveBeenCalled ( ) ;
707+ } ) ;
708+
709+ it ( 'should publish user-defined product subscription' , async ( ) => {
710+ const client = createMockClient ( ) ;
711+ const store = createMockStore ( ) ;
712+
713+ const armScopePrefix =
714+ '/subscriptions/sub-1/resourceGroups/rg-1/providers/Microsoft.ApiManagement/service/apim-1' ;
715+
716+ const subscriptionJson = {
717+ name : 'team-a-product-sub' ,
718+ properties : {
719+ scope : `${ armScopePrefix } /products/starter` ,
720+ displayName : 'Team A starter product' ,
721+ state : 'active' ,
722+ } ,
723+ } ;
724+ store . readResource . mockResolvedValue ( subscriptionJson ) ;
725+
726+ const descriptor : ResourceDescriptor = {
727+ type : ResourceType . Subscription ,
728+ nameParts : [ 'team-a-product-sub' ] ,
729+ } ;
730+
731+ const result = await publishResource ( client , store , testContext , descriptor , testConfig ) ;
732+
704733 expect ( result . status ) . toBe ( 'success' ) ;
705734 expect ( result . action ) . toBe ( 'put' ) ;
706735 expect ( client . putResource ) . toHaveBeenCalledTimes ( 1 ) ;
0 commit comments