-
Notifications
You must be signed in to change notification settings - Fork 0
/
workbook_test.go
44 lines (37 loc) · 1.11 KB
/
workbook_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package xlsx
import (
"os"
"testing"
)
func Test_Workbook_AddWorksheet_ShouldProperlyAddNewWorksheet_WhenGivenValidArguments(t *testing.T) {
wb := NewWorkbook("./spreadsheet.xlsx")
wsName := "Sheet 1"
ws := wb.AddWorksheet(&WorksheetOptions{
Name: wsName,
})
if ws.name != wsName {
t.Errorf("worksheet name differs from the one given to AddWorksheet, expected \"%s\", found \"%s\"", wsName, ws.name)
return
}
if ws.fileName != "sheet1.xml" {
t.Errorf("worksheet file name is wrong, expected \"sheet1.xml\", found \"%s\"", ws.fileName)
return
}
}
func Test_Workbook_createTempDirs_ShouldProperlyCreateTemporaryDirectories(t *testing.T) {
wb := NewWorkbook("./spreadsheet.xlsx")
err := wb.createTempDirs()
if err != nil {
t.Errorf("failed to create the temporary directories: %v", err)
return
}
// TODO: Check if directories were actually created
if !wb.tempDirsCreated {
t.Error("unexpected value for Workbook.tempDirsCreated, expected: true, found: false")
}
err = os.RemoveAll(wb.tempRootDir)
if err != nil {
t.Errorf("failed to remove the temporary directories: %v", err)
return
}
}