@@ -576,6 +576,42 @@ describe('FilesRepository', () => {
576576 } )
577577 } )
578578
579+ describe ( 'updateFileMetadata' , ( ) => {
580+ test ( 'should return error when file does not exist' , async ( ) => {
581+ const nonExistentFiledId = 4000
582+ const testFileMetadata = {
583+ description : 'My description bbb.' ,
584+ categories : [ 'Data' ] ,
585+ restrict : false
586+ }
587+ const errorExpected = new WriteError ( `[400] Error attempting get the requested data file.` )
588+
589+ await expect ( sut . updateFileMetadata ( nonExistentFiledId , testFileMetadata ) ) . rejects . toThrow (
590+ errorExpected
591+ )
592+ } )
593+
594+ test ( 'should update file metadata when file exists' , async ( ) => {
595+ const getDatasetFilesResponse = await sut . getDatasetFiles (
596+ testDatasetIds . numericId ,
597+ latestDatasetVersionId ,
598+ false ,
599+ FileOrderCriteria . NAME_AZ
600+ )
601+
602+ const fileId = getDatasetFilesResponse . files [ 0 ] . id
603+ const testFileMetadata = {
604+ description : 'My description bbb.' ,
605+ categories : [ 'Data' ] ,
606+ restrict : false
607+ }
608+
609+ const actual = await sut . updateFileMetadata ( fileId , testFileMetadata )
610+
611+ expect ( actual ) . toBeUndefined ( )
612+ } )
613+ } )
614+
579615 describe ( 'getFileUploadDestination' , ( ) => {
580616 const testCollectionAlias = 'getFileUploadDestinationsTestCollection'
581617 let testDataset2Ids : CreatedDatasetIdentifiers
@@ -646,42 +682,4 @@ describe('FilesRepository', () => {
646682 ) . rejects . toThrow ( errorExpected )
647683 } )
648684 } )
649-
650- describe ( 'updateFileMetadata' , ( ) => {
651- test ( 'should return error when file does not exist' , async ( ) => {
652- const nonExistentFiledId = 4000
653- const testFileMetadata = {
654- description : 'My description bbb.' ,
655- categories : [ 'Data' ] ,
656- restrict : false
657- }
658- const errorExpected = new WriteError ( `[400] Error attempting get the requested data file.` )
659-
660- await expect ( sut . updateFileMetadata ( nonExistentFiledId , testFileMetadata ) ) . rejects . toThrow (
661- errorExpected
662- )
663- } )
664-
665- test ( 'should update file metadata when file exists' , async ( ) => {
666- const getDatasetFilesResponse = await sut . getDatasetFiles (
667- testDatasetIds . numericId ,
668- latestDatasetVersionId ,
669- false ,
670- FileOrderCriteria . NAME_AZ
671- )
672-
673- console . log ( 'fileInfo' , getDatasetFilesResponse )
674-
675- const fileId = getDatasetFilesResponse . files [ 0 ] . id
676- const testFileMetadata = {
677- description : 'My description bbb.' ,
678- categories : [ 'Data' ] ,
679- restrict : false
680- }
681-
682- const actual = await sut . updateFileMetadata ( fileId , testFileMetadata )
683-
684- expect ( actual ) . toBeUndefined ( )
685- } )
686- } )
687685} )
0 commit comments