Skip to content

Commit

Permalink
Merge pull request #428 from nfdi4plants/fixes
Browse files Browse the repository at this point in the history
Fix single dot in paths being interpreted as folder
  • Loading branch information
HLWeil authored Aug 29, 2024
2 parents 8ebf316 + bfaaaf6 commit 5e6cc32
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/FileSystem/Path.fs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ let [<Literal>] StudiesResourcesFolderName = "resources"

let split(path: string) =
path.Split(seperators, enum<StringSplitOptions>(3))
|> Array.filter (fun p -> p <> "" && p <> ".")

let combine (path1 : string) (path2 : string) : string =
let path1_trimmed = path1.TrimEnd(seperators)
Expand Down
21 changes: 17 additions & 4 deletions tests/ARCtrl/ARCtrl.Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@ open ARCtrl.Spreadsheet
open ARCtrl.Helper
open FsSpreadsheet

let private tests_model = testList "model" [
testCase "create" <| fun _ ->
let tests_create = testList "create" [
testCase "empty" <| fun _ ->
let arc = ARC()
Expect.isNone arc.CWL "cwl"
Expect.isNone arc.ISA "isa"
testCase "fromFilePath" <| fun _ ->
]

let private tests_fromFilePaths = testList "fromFilePaths" [

testCase "simple" <| fun _ ->
let input =
[|@"isa.investigation.xlsx"; @".arc\.gitkeep"; @".git\config";
@".git\description"; @".git\HEAD"; @"assays\.gitkeep"; @"runs\.gitkeep";
Expand Down Expand Up @@ -47,6 +51,14 @@ let private tests_model = testList "model" [
Expect.isNone arc.ISA "isa"
let actualFilePaths = arc.FileSystem.Tree.ToFilePaths() |> Array.sort
Expect.equal actualFilePaths input "isSome fs"
testCase "correctContractsFor(.)AtBeginning" <| fun _ ->
let input = [|
@"./isa.investigation.xlsx"
@"./assays/TestAssay1/isa.assay.xlsx"
@"./studies/TestAssay1/isa.study.xlsx";|]
let arc = ARC.fromFilePaths(input)
let contracts = arc.GetReadContracts()
Expect.hasLength contracts 3 "should have read 3 contracts"
]

let private simpleISAContracts =
Expand Down Expand Up @@ -931,7 +943,8 @@ let tests_RenameStudy = testList "RenameStudy" [
]

let main = testList "ARCtrl" [
tests_model
tests_create
tests_fromFilePaths
tests_updateFileSystem
tests_read_contracts
tests_writeContracts
Expand Down

0 comments on commit 5e6cc32

Please sign in to comment.