@@ -335,6 +335,88 @@ let private tests_updateContracts = testList "update_contracts" [
335335 Expect.exists contracts ( fun c -> c.Path = " isa.investigation.xlsx" ) " Contract for investigation folder missing"
336336 Expect.exists contracts ( fun c -> c.Path = " isa.investigation.xlsx" && c.DTOType.IsSome && c.DTOType.Value = Contract.DTOType.ISA_ Investigation) " Contract for investigation exisiting but has wrong DTO type"
337337 )
338+ testCase " empty_addAssay" ( fun _ ->
339+ let i = ArcInvestigation( " MyInvestigation" )
340+ let arc = ARC( isa = i)
341+ arc.GetWriteContracts() |> ignore
342+ i.InitAssay( " MyAssay" ) |> ignore
343+ // As the ARC is compeletely empty, GetUpdateContracts should return the same contracts as GetWriteContracts
344+ let contracts = arc.GetUpdateContracts()
345+ let contractPathsString = contracts |> Array.map ( fun c -> c.Path) |> String.concat " , "
346+ Expect.equal contracts.Length 4 $" Should contain exactly as much contracts as needed for new assay: {contractPathsString}"
347+ // Assay file contract
348+ let assayFilePath = " assays/MyAssay/isa.assay.xlsx"
349+ let assayFileContract = Expect.wantSome ( contracts |> Array.tryFind ( fun c -> c.Path = assayFilePath)) $" Assay file contract for {assayFilePath} missing"
350+ Expect.equal assayFileContract.Operation Operation.CREATE " Operation for assay file contract should be CREATE"
351+ let assayFileDTOType = Expect.wantSome assayFileContract.DTOType " DTOType for assay file contract missing"
352+ Expect.equal assayFileDTOType DTOType.ISA_ Assay " DTOType for assay file contract should be ISA_Assay"
353+ let assayFileDTO = Expect.wantSome assayFileContract.DTO " DTO for assay file contract missing"
354+ let wb = assayFileDTO.AsSpreadsheet() :?> FsWorkbook
355+ let assay = ArcAssay.fromFsWorkbook wb
356+ Expect.equal assay.Identifier " MyAssay" " Assay identifier should be set"
357+ // readme contract
358+ let readmeFilePath = " assays/MyAssay/README.md"
359+ let readmeContract = Expect.wantSome ( contracts |> Array.tryFind ( fun c -> c.Path = readmeFilePath)) $" Readme contract for {readmeFilePath} missing"
360+ Expect.equal readmeContract.Operation Operation.CREATE " Operation for readme contract should be CREATE"
361+ let readmeDTOType = Expect.wantSome readmeContract.DTOType " DTOType for readme contract missing"
362+ Expect.equal readmeDTOType DTOType.PlainText " DTOType for readme contract should be ISA_Readme"
363+ Expect.isNone readmeContract.DTO " DTO for readme contract should be None"
364+ // protocols gitkeep contract
365+ let protocolsGitkeepFilePath = " assays/MyAssay/protocols/.gitkeep"
366+ let protocolsGitkeepContract = Expect.wantSome ( contracts |> Array.tryFind ( fun c -> c.Path = protocolsGitkeepFilePath)) $" Protocols gitkeep contract for {protocolsGitkeepFilePath} missing"
367+ Expect.equal protocolsGitkeepContract.Operation Operation.CREATE " Operation for protocols gitkeep contract should be CREATE"
368+ let protocolsGitkeepDTOType = Expect.wantSome protocolsGitkeepContract.DTOType " DTOType for protocols gitkeep contract missing"
369+ Expect.equal protocolsGitkeepDTOType DTOType.PlainText " DTOType for protocols gitkeep contract should be GitKeep"
370+ Expect.isNone protocolsGitkeepContract.DTO " DTO for protocols gitkeep contract should be None"
371+ // dataset gitkeep contract
372+ let datasetGitkeepFilePath = " assays/MyAssay/dataset/.gitkeep"
373+ let datasetGitkeepContract = Expect.wantSome ( contracts |> Array.tryFind ( fun c -> c.Path = datasetGitkeepFilePath)) $" Dataset gitkeep contract for {datasetGitkeepFilePath} missing"
374+ Expect.equal datasetGitkeepContract.Operation Operation.CREATE " Operation for dataset gitkeep contract should be CREATE"
375+ let datasetGitkeepDTOType = Expect.wantSome datasetGitkeepContract.DTOType " DTOType for dataset gitkeep contract missing"
376+ Expect.equal datasetGitkeepDTOType DTOType.PlainText " DTOType for dataset gitkeep contract should be GitKeep"
377+ Expect.isNone datasetGitkeepContract.DTO " DTO for dataset gitkeep contract should be None"
378+ )
379+ testCase " empty_addStudy" ( fun _ ->
380+ let i = ArcInvestigation( " MyInvestigation" )
381+ let arc = ARC( isa = i)
382+ arc.GetWriteContracts() |> ignore
383+ i.InitStudy( " MyStudy" ) |> ignore
384+ // As the ARC is compeletely empty, GetUpdateContracts should return the same contracts as GetWriteContracts
385+ let contracts = arc.GetUpdateContracts()
386+ let contractPathsString = contracts |> Array.map ( fun c -> c.Path) |> String.concat " , "
387+ Expect.equal contracts.Length 4 $" Should contain exactly as much contracts as needed for new study: {contractPathsString}"
388+ // Study file contract
389+ let studyFilePath = " studies/MyStudy/isa.study.xlsx"
390+ let studyFileContract = Expect.wantSome ( contracts |> Array.tryFind ( fun c -> c.Path = studyFilePath)) $" Study file contract for {studyFilePath} missing"
391+ Expect.equal studyFileContract.Operation Operation.CREATE " Operation for study file contract should be CREATE"
392+ let studyFileDTOType = Expect.wantSome studyFileContract.DTOType " DTOType for study file contract missing"
393+ Expect.equal studyFileDTOType DTOType.ISA_ Study " DTOType for study file contract should be ISA_Study"
394+ let studyFileDTO = Expect.wantSome studyFileContract.DTO " DTO for study file contract missing"
395+ let wb = studyFileDTO.AsSpreadsheet() :?> FsWorkbook
396+ let study , _ = ArcStudy.fromFsWorkbook wb
397+ Expect.equal study.Identifier " MyStudy" " Study identifier should be set"
398+ // readme contract
399+ let readmeFilePath = " studies/MyStudy/README.md"
400+ let readmeContract = Expect.wantSome ( contracts |> Array.tryFind ( fun c -> c.Path = readmeFilePath)) $" Readme contract for {readmeFilePath} missing"
401+ Expect.equal readmeContract.Operation Operation.CREATE " Operation for readme contract should be CREATE"
402+ let readmeDTOType = Expect.wantSome readmeContract.DTOType " DTOType for readme contract missing"
403+ Expect.equal readmeDTOType DTOType.PlainText " DTOType for readme contract should be ISA_Readme"
404+ Expect.isNone readmeContract.DTO " DTO for readme contract should be None"
405+ // protocols gitkeep contract
406+ let protocolsGitkeepFilePath = " studies/MyStudy/protocols/.gitkeep"
407+ let protocolsGitkeepContract = Expect.wantSome ( contracts |> Array.tryFind ( fun c -> c.Path = protocolsGitkeepFilePath)) $" Protocols gitkeep contract for {protocolsGitkeepFilePath} missing"
408+ Expect.equal protocolsGitkeepContract.Operation Operation.CREATE " Operation for protocols gitkeep contract should be CREATE"
409+ let protocolsGitkeepDTOType = Expect.wantSome protocolsGitkeepContract.DTOType " DTOType for protocols gitkeep contract missing"
410+ Expect.equal protocolsGitkeepDTOType DTOType.PlainText " DTOType for protocols gitkeep contract should be GitKeep"
411+ Expect.isNone protocolsGitkeepContract.DTO " DTO for protocols gitkeep contract should be None"
412+ // resources gitkeep contract
413+ let resourcesGitkeepFilePath = " studies/MyStudy/resources/.gitkeep"
414+ let resourcesGitkeepContract = Expect.wantSome ( contracts |> Array.tryFind ( fun c -> c.Path = resourcesGitkeepFilePath)) $" Resources gitkeep contract for {resourcesGitkeepFilePath} missing"
415+ Expect.equal resourcesGitkeepContract.Operation Operation.CREATE " Operation for resources gitkeep contract should be CREATE"
416+ let resourcesGitkeepDTOType = Expect.wantSome resourcesGitkeepContract.DTOType " DTOType for resources gitkeep contract missing"
417+ Expect.equal resourcesGitkeepDTOType DTOType.PlainText " DTOType for resources gitkeep contract should be GitKeep"
418+ Expect.isNone resourcesGitkeepContract.DTO " DTO for resources gitkeep contract should be None"
419+ )
338420 testCase " init_simpleISA" ( fun _ ->
339421 let inv = ArcInvestigation( " MyInvestigation" , " BestTitle" )
340422 inv.InitStudy( " MyStudy" ) .InitRegisteredAssay( " MyAssay" ) |> ignore
0 commit comments