Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test and fix empty table io #301

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/ISA/ISA.Spreadsheet/AnnotationTable/ArcTable.fs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ let toFsWorksheet (table : ArcTable) =
/// This dictionary is used to add spaces at the end of duplicate headers.
let stringCount = System.Collections.Generic.Dictionary<string,string>()
let ws = FsWorksheet(table.Name)

// Cancel if there are no columns
if table.Columns.Length = 0 then ws
else

let columns =
table.Columns
|> List.ofArray
Expand Down
22 changes: 19 additions & 3 deletions tests/ISA/ISA.Spreadsheet.Tests/ArcTableTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ let private simpleTable =
)
]

let private emptyTable =
testList "emptyTable" [
let private valuelessTable =
testList "valuelessTable" [
let wsName = "MyWorksheet"
let ws =
initWorksheet wsName
Expand Down Expand Up @@ -363,14 +363,30 @@ let private writeOrder =
)
]

let private emptyTable =
testList "emptyTable" [
let name = "EmptyTable"
let t = ArcTable.init(name)
testCase "Write" (fun () ->
let sheet = ArcTable.toFsWorksheet t
Expect.equal name sheet.Name "Worksheet name did not match"
Expect.equal 0 sheet.Rows.Count "Row count should be 0"
)
testCase "Read" (fun () ->
let sheet = ArcTable.toFsWorksheet t
Expect.isNone (ArcTable.tryFromFsWorksheet sheet) "Table was not created"
)
]

let main =
testList "ArcTableTests" [
ensureCorrectTestHeaders
groupCols
simpleTable
mixedTable
ioTable
emptyTable
valuelessTable
deprecatedColumnTable
writeOrder
emptyTable
]
Loading