@@ -703,20 +703,23 @@ describe('Secret Manager samples', () => {
703703 } ,
704704 } ) ;
705705
706- const output = execSync (
707- `node disableSecretDelayedDestroy.js ${ fullSecretName } `
708- ) ;
709- assert . match ( output , new RegExp ( 'Disabled delayed destroy' ) ) ;
710-
711- await client . deleteSecret ( {
712- name : fullSecretName ,
713- } ) ;
706+ try {
707+ const output = execSync (
708+ `node disableSecretDelayedDestroy.js ${ fullSecretName } `
709+ ) ;
710+ assert . match ( output , new RegExp ( 'Disabled delayed destroy' ) ) ;
711+ } finally {
712+ await client . deleteSecret ( {
713+ name : fullSecretName ,
714+ } ) ;
715+ }
714716 } ) ;
715717
716718 it ( 'updates a secret delayed destroy' , async ( ) => {
717719 const customSecretId = `${ secretId } -${ v4 ( ) } ` ;
718720 const fullSecretName = `projects/${ projectId } /secrets/${ customSecretId } ` ;
719721 const updatedTimeToLive = 24 * 60 * 60 * 2 ;
722+
720723 await client . createSecret ( {
721724 parent : `projects/${ projectId } ` ,
722725 secretId : customSecretId ,
@@ -730,13 +733,16 @@ describe('Secret Manager samples', () => {
730733 } ,
731734 } ) ;
732735
733- const output = execSync (
734- `node updateSecretWithDelayedDestroy.js ${ fullSecretName } ${ updatedTimeToLive } `
735- ) ;
736- assert . match ( output , new RegExp ( 'Updated secret' ) ) ;
737- await client . deleteSecret ( {
738- name : fullSecretName ,
739- } ) ;
736+ try {
737+ const output = execSync (
738+ `node updateSecretWithDelayedDestroy.js ${ fullSecretName } ${ updatedTimeToLive } `
739+ ) ;
740+ assert . match ( output , new RegExp ( 'Updated secret' ) ) ;
741+ } finally {
742+ await client . deleteSecret ( {
743+ name : fullSecretName ,
744+ } ) ;
745+ }
740746 } ) ;
741747
742748 it ( 'creates a regional secret with delayed destroy' , async ( ) => {
@@ -761,14 +767,16 @@ describe('Secret Manager samples', () => {
761767 } ,
762768 } ) ;
763769
764- const output = execSync (
765- `node regional_samples/disableRegionalSecretDelayedDestroy.js ${ projectId } ${ locationId } ${ customSecretId } `
766- ) ;
767- assert . match ( output , new RegExp ( 'Disabled delayed destroy' ) ) ;
768-
769- await regionalClient . deleteSecret ( {
770- name : fullSecretName ,
771- } ) ;
770+ try {
771+ const output = execSync (
772+ `node regional_samples/disableRegionalSecretDelayedDestroy.js ${ projectId } ${ locationId } ${ customSecretId } `
773+ ) ;
774+ assert . match ( output , new RegExp ( 'Disabled delayed destroy' ) ) ;
775+ } finally {
776+ await regionalClient . deleteSecret ( {
777+ name : fullSecretName ,
778+ } ) ;
779+ }
772780 } ) ;
773781
774782 it ( 'updates a regional secret delayed destroy' , async ( ) => {
@@ -786,13 +794,16 @@ describe('Secret Manager samples', () => {
786794 } ,
787795 } ) ;
788796
789- const output = execSync (
790- `node regional_samples/updateRegionalSecretWithDelayedDestroy.js ${ projectId } ${ locationId } ${ customSecretId } ${ updatedTimeToLive } `
791- ) ;
792- assert . match ( output , new RegExp ( 'Updated regional secret' ) ) ;
793- await regionalClient . deleteSecret ( {
794- name : fullSecretName ,
795- } ) ;
797+ try {
798+ const output = execSync (
799+ `node regional_samples/updateRegionalSecretWithDelayedDestroy.js ${ projectId } ${ locationId } ${ customSecretId } ${ updatedTimeToLive } `
800+ ) ;
801+ assert . match ( output , new RegExp ( 'Updated regional secret' ) ) ;
802+ } finally {
803+ await regionalClient . deleteSecret ( {
804+ name : fullSecretName ,
805+ } ) ;
806+ }
796807 } ) ;
797808
798809 it ( 'creates secret with tags' , async ( ) => {
0 commit comments