@@ -534,6 +534,41 @@ describe('FilesRepository', () => {
534534 } )
535535 } )
536536
537+ describe ( 'updateFileMetadata' , ( ) => {
538+ test ( 'should return error when file does not exist' , async ( ) => {
539+ const testFileMetadata = {
540+ description : 'My description bbb.' ,
541+ categories : [ 'Data' ] ,
542+ restrict : false
543+ }
544+ const errorExpected = new WriteError ( `[400] Error attempting get the requested data file.` )
545+
546+ await expect ( sut . updateFileMetadata ( nonExistentFiledId , testFileMetadata ) ) . rejects . toThrow (
547+ errorExpected
548+ )
549+ } )
550+
551+ test ( 'should update file metadata when file exists' , async ( ) => {
552+ const getDatasetFilesResponse = await sut . getDatasetFiles (
553+ testDatasetIds . numericId ,
554+ latestDatasetVersionId ,
555+ false ,
556+ FileOrderCriteria . NAME_AZ
557+ )
558+
559+ const fileId = getDatasetFilesResponse . files [ 0 ] . id
560+ const testFileMetadata = {
561+ description : 'My description bbb.' ,
562+ categories : [ 'Data' ] ,
563+ restrict : false
564+ }
565+
566+ const actual = await sut . updateFileMetadata ( fileId , testFileMetadata )
567+
568+ expect ( actual ) . toBeUndefined ( )
569+ } )
570+ } )
571+
537572 describe ( 'getFileCitation' , ( ) => {
538573 test ( 'should return citation when file exists' , async ( ) => {
539574 const actualFileCitation = await sut . getFileCitation (
@@ -576,61 +611,6 @@ describe('FilesRepository', () => {
576611 } )
577612 } )
578613
579- describe ( 'updateFileMetadata' , ( ) => {
580- const testCollectionAlias = 'updateFileMetadataTestCollection'
581- let testDataset2Ids : CreatedDatasetIdentifiers
582-
583- beforeAll ( async ( ) => {
584- await createCollectionViaApi ( testCollectionAlias )
585- await setStorageDriverViaApi ( testCollectionAlias , 'LocalStack' )
586- testDataset2Ids = await createDataset . execute (
587- TestConstants . TEST_NEW_DATASET_DTO ,
588- testCollectionAlias
589- )
590- await createSinglepartFileBlob ( )
591- await createMultipartFileBlob ( )
592- } )
593-
594- afterAll ( async ( ) => {
595- await deleteUnpublishedDatasetViaApi ( testDataset2Ids . numericId )
596- await deleteCollectionViaApi ( testCollectionAlias )
597- } )
598-
599- test ( 'should return error when file does not exist' , async ( ) => {
600- const nonExistentFiledId = 4000
601- const testFileMetadata = {
602- description : 'My description bbb.' ,
603- categories : [ 'Data' ] ,
604- restrict : false
605- }
606- const errorExpected = new WriteError ( `[400] Error attempting get the requested data file.` )
607-
608- await expect ( sut . updateFileMetadata ( nonExistentFiledId , testFileMetadata ) ) . rejects . toThrow (
609- errorExpected
610- )
611- } )
612-
613- test ( 'should update file metadata when file exists' , async ( ) => {
614- const getDatasetFilesResponse = await sut . getDatasetFiles (
615- testDataset2Ids . numericId ,
616- latestDatasetVersionId ,
617- false ,
618- FileOrderCriteria . NAME_AZ
619- )
620-
621- const fileId = getDatasetFilesResponse . files [ 0 ] . id
622- const testFileMetadata = {
623- description : 'My description bbb.' ,
624- categories : [ 'Data' ] ,
625- restrict : false
626- }
627-
628- const actual = await sut . updateFileMetadata ( fileId , testFileMetadata )
629-
630- expect ( actual ) . toBeUndefined ( )
631- } )
632- } )
633-
634614 describe ( 'getFileUploadDestination' , ( ) => {
635615 const testCollectionAlias = 'getFileUploadDestinationsTestCollection'
636616 let testDataset2Ids : CreatedDatasetIdentifiers
0 commit comments