Skip to content

Commit 4d1bb7a

Browse files
committed
add test against distinct ro-crate process ids for same table names
1 parent 999505f commit 4d1bb7a

1 file changed

Lines changed: 31 additions & 1 deletion

File tree

tests/ARCtrl/ROCrateConversion.Tests.fs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,6 @@ let private tests_ArcTableProcess =
896896
let expectedTable = t
897897
Expect.arcTableEqual table expectedTable "Table should be equal"
898898
)
899-
900899
]
901900

902901
let private tests_DataContext =
@@ -1620,6 +1619,37 @@ let tests_Investigation =
16201619
p'.PublicReleaseDate <- None // As a default value is used otherwise
16211620
Expect.equal p' p "Investigation should match"
16221621
)
1622+
// This test is meant to check, that two processes created from two different tables with the same name are distinctly named
1623+
// This is important to ensure they are not merged
1624+
// https://github.com/nfdi4plants/ARCtrl/issues/514
1625+
ftestCase "DistinctProcessNaming" (fun () ->
1626+
// Setup
1627+
let arc = ArcInvestigation("MyArc", title = "MyTitle")
1628+
let study1 = arc.InitStudy "Study1"
1629+
let study2 = arc.InitStudy "Study2"
1630+
let table1 = study1.InitTable("Growth")
1631+
let table2 = study2.InitTable("Growth")
1632+
table1.AddColumn(CompositeHeader.Input(IOType.Source),[|CompositeCell.createFreeText "Source"|])
1633+
table2.AddColumn(CompositeHeader.Input(IOType.Sample),[|CompositeCell.createFreeText "Sample"|])
1634+
// Check Json LD
1635+
let ro_Investigation = InvestigationConversion.composeInvestigation arc
1636+
let subDatasets = ro_Investigation |> LDDataset.getHasPartsAsDataset
1637+
let s1 = Expect.wantSome (subDatasets |> Seq.tryFind (fun s -> s.Id = "studies/Study1/")) "Study1 should exist"
1638+
let s2 = Expect.wantSome (subDatasets |> Seq.tryFind (fun s -> s.Id = "studies/Study2/")) "Study2 should exist"
1639+
let p1 = Expect.wantSome (s1 |> LDDataset.getAboutsAsLabProcess |> Seq.tryExactlyOne) "Study1 should have a process"
1640+
let p2 = Expect.wantSome (s2 |> LDDataset.getAboutsAsLabProcess |> Seq.tryExactlyOne) "Study2 should have a process"
1641+
Expect.notEqual p1.Id p2.Id "Processes should have different Ids"
1642+
// Check reparsed scaffold
1643+
let arc' = InvestigationConversion.decomposeInvestigation(ro_Investigation)
1644+
let study1' = Expect.wantSome (arc'.TryGetStudy("Study1")) "Study1 should exist"
1645+
let study2' = Expect.wantSome (arc'.TryGetStudy("Study2")) "Study2 should exist"
1646+
Expect.equal study1'.TableCount 1 "Study1 should have one table"
1647+
Expect.equal study2'.TableCount 1 "Study2 should have one table"
1648+
let table1' = study1'.GetTable("Growth")
1649+
let table2' = study2'.GetTable("Growth")
1650+
Expect.arcTableEqual table1' table1 "Table1 should match"
1651+
Expect.arcTableEqual table2' table2 "Table2 should match"
1652+
)
16231653
]
16241654

16251655

0 commit comments

Comments
 (0)