From 2e3e954874443d6f9e307fd31f566e279f4b46db Mon Sep 17 00:00:00 2001
From: Nobuhiro Iwamatsu <iwamatsu@debian.org>
Date: Mon, 31 Dec 2018 21:02:37 +0900
Subject: [PATCH] Change path of test files

Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@debian.org>
---
 compatibility_test.go | 18 +++++++++----
 file_test.go          | 61 +++++++++++++++++++++++++++++--------------
 lib_test.go           | 24 ++++++++++-------
 3 files changed, 69 insertions(+), 34 deletions(-)

diff --git a/compatibility_test.go b/compatibility_test.go
index 69a1241..b675af3 100644
--- a/compatibility_test.go
+++ b/compatibility_test.go
@@ -1,6 +1,10 @@
 package xlsx
 
-import . "gopkg.in/check.v1"
+import (
+	"os"
+
+	. "gopkg.in/check.v1"
+)
 
 type GoogleDocsExcelSuite struct{}
 
@@ -9,7 +13,8 @@ var _ = Suite(&GoogleDocsExcelSuite{})
 // Test that we can successfully read an XLSX file generated by
 // Google Docs.
 func (g *GoogleDocsExcelSuite) TestGoogleDocsExcel(c *C) {
-	xlsxFile, err := OpenFile("./testdocs/googleDocsTest.xlsx")
+	wd_path, _ := os.Getwd()
+	xlsxFile, err := OpenFile(wd_path + "/../../../../../testdocs/googleDocsTest.xlsx")
 	c.Assert(err, IsNil)
 	c.Assert(xlsxFile, NotNil)
 }
@@ -23,7 +28,8 @@ var _ = Suite(&MacExcelSuite{})
 // respect the contents of workbook.xml.rels, which maps the sheet IDs
 // to their internal file names.
 func (m *MacExcelSuite) TestMacExcel(c *C) {
-	xlsxFile, err := OpenFile("./testdocs/macExcelTest.xlsx")
+	wd_path, _ := os.Getwd()
+	xlsxFile, err := OpenFile(wd_path + "/../../../../../testdocs/macExcelTest.xlsx")
 	c.Assert(err, IsNil)
 	c.Assert(xlsxFile, NotNil)
 	if val, err := xlsxFile.Sheet["普通技能"].Cell(0, 0).FormattedValue(); err != nil {
@@ -40,7 +46,8 @@ var _ = Suite(&MacNumbersSuite{})
 // Test that we can successfully read an XLSX file generated by
 // Numbers for Mac.
 func (m *MacNumbersSuite) TestMacNumbers(c *C) {
-	xlsxFile, err := OpenFile("./testdocs/macNumbersTest.xlsx")
+	wd_path, _ := os.Getwd()
+	xlsxFile, err := OpenFile(wd_path + "/../../../../../testdocs/macNumbersTest.xlsx")
 	c.Assert(err, IsNil)
 	c.Assert(xlsxFile, NotNil)
 	sheet, ok := xlsxFile.Sheet["主动技能"]
@@ -59,7 +66,8 @@ var _ = Suite(&WorksheetSuite{})
 // Test that we can successfully read an XLSX file generated by
 // Wps on windows. you can download it freely from http://www.wps.cn/
 func (w *WpsBlankLineSuite) TestWpsBlankLine(c *C) {
-	xlsxFile, err := OpenFile("./testdocs/wpsBlankLineTest.xlsx")
+	wd_path, _ := os.Getwd()
+	xlsxFile, err := OpenFile(wd_path + "/../../../../../testdocs/wpsBlankLineTest.xlsx")
 	c.Assert(err, IsNil)
 	c.Assert(xlsxFile, NotNil)
 	sheet := xlsxFile.Sheet["Sheet1"]
diff --git a/file_test.go b/file_test.go
index 0b7377c..ef50b39 100644
--- a/file_test.go
+++ b/file_test.go
@@ -55,7 +55,8 @@ func (l *FileSuite) TestOpenFile(c *C) {
 	var xlsxFile *File
 	var err error
 
-	xlsxFile, err = OpenFile("./testdocs/testfile.xlsx")
+	wd_path, _ := os.Getwd()
+	xlsxFile, err = OpenFile(wd_path + "/../../../../../testdocs/testfile.xlsx")
 	c.Assert(err, IsNil)
 	c.Assert(xlsxFile, NotNil)
 }
@@ -69,7 +70,8 @@ func (l *FileSuite) TestPartialReadsWithFewSharedStringsOnlyPartiallyReads(c *C)
 	// to anywhere near a significant amount of 11 million. We're testing that this number is low, to ensure that partial
 	// reads are fast.
 	readLimit := 20 * 1000
-	reader, size, err := NewReaderAtCounter("testdocs/large_sheet_no_shared_strings_no_dimension_tag.xlsx")
+	wd_path, _ := os.Getwd()
+	reader, size, err := NewReaderAtCounter(wd_path + "/../../../../../testdocs/large_sheet_no_shared_strings_no_dimension_tag.xlsx")
 	if err != nil {
 		c.Fatal(err)
 	}
@@ -95,7 +97,8 @@ func (l *FileSuite) TestPartialReadsWithLargeSharedStringsOnlyPartiallyReads(c *
 	// to anywhere near a significant amount of 7 million. We're testing that this number is low, to ensure that partial
 	// reads are fast.
 	readLimit := int(1.2 * 1000 * 1000)
-	reader, size, err := NewReaderAtCounter("testdocs/large_sheet_large_sharedstrings_dimension_tag.xlsx")
+	wd_path, _ := os.Getwd()
+	reader, size, err := NewReaderAtCounter(wd_path + "/../../../../../testdocs/large_sheet_large_sharedstrings_dimension_tag.xlsx")
 	if err != nil {
 		c.Fatal(err)
 	}
@@ -114,7 +117,9 @@ func (l *FileSuite) TestPartialReadsWithLargeSharedStringsOnlyPartiallyReads(c *
 
 func (l *FileSuite) TestPartialReadsWithFewerRowsThanRequested(c *C) {
 	rowLimit := 10
-	file, err := OpenFileWithRowLimit("testdocs/testfile.xlsx", rowLimit)
+
+	wd_path, _ := os.Getwd()
+	file, err := OpenFileWithRowLimit(wd_path + "/../../../../../testdocs/testfile.xlsx", rowLimit)
 	if err != nil {
 		c.Fatal(err)
 	}
@@ -127,13 +132,15 @@ func (l *FileSuite) TestOpenFileWithoutStyleAndSharedStrings(c *C) {
 	var xlsxFile *File
 	var error error
 
-	xlsxFile, error = OpenFile("./testdocs/noStylesAndSharedStringsTest.xlsx")
+	wd_path, _ := os.Getwd()
+	xlsxFile, error = OpenFile(wd_path + "/../../../../../testdocs/noStylesAndSharedStringsTest.xlsx")
 	c.Assert(error, IsNil)
 	c.Assert(xlsxFile, NotNil)
 }
 
 func (l *FileSuite) TestOpenFileWithChartsheet(c *C) {
-	xlsxFile, error := OpenFile("./testdocs/testchartsheet.xlsx")
+	wd_path, _ := os.Getwd()
+	xlsxFile, error := OpenFile(wd_path + "/../../../../../testdocs/testchartsheet.xlsx")
 	c.Assert(error, IsNil)
 	c.Assert(xlsxFile, NotNil)
 }
@@ -144,7 +151,9 @@ func (l *FileSuite) TestOpenFileWithChartsheet(c *C) {
 func (l *FileSuite) TestReadSharedStringsFromZipFile(c *C) {
 	var xlsxFile *File
 	var err error
-	xlsxFile, err = OpenFile("./testdocs/testfile.xlsx")
+
+	wd_path, _ := os.Getwd()
+	xlsxFile, err = OpenFile(wd_path + "/../../../../../testdocs/testfile.xlsx")
 	c.Assert(err, IsNil)
 	c.Assert(xlsxFile.referenceTable, NotNil)
 }
@@ -174,7 +183,8 @@ func (l *FileSuite) TestReadStylesFromZipFile(c *C) {
 	var border xlsxBorder
 	var xf xlsxXf
 
-	xlsxFile, err = OpenFile("./testdocs/testfile.xlsx")
+	wd_path, _ := os.Getwd()
+	xlsxFile, err = OpenFile(wd_path + "/../../../../../testdocs/testfile.xlsx")
 	c.Assert(err, IsNil)
 	c.Assert(xlsxFile.styles, NotNil)
 
@@ -247,7 +257,8 @@ func (l *FileSuite) TestReadWorkbookRelationsFromZipFile(c *C) {
 	var xlsxFile *File
 	var err error
 
-	xlsxFile, err = OpenFile("./testdocs/testfile.xlsx")
+	wd_path, _ := os.Getwd()
+	xlsxFile, err = OpenFile(wd_path + "/../../../../../testdocs/testfile.xlsx")
 	c.Assert(err, IsNil)
 	c.Assert(len(xlsxFile.Sheets), Equals, 3)
 	sheet, ok := xlsxFile.Sheet["Tabelle1"]
@@ -262,7 +273,8 @@ func (l *FileSuite) TestGetStyleFromZipFile(c *C) {
 	var style *Style
 	var val string
 
-	xlsxFile, err = OpenFile("./testdocs/testfile.xlsx")
+	wd_path, _ := os.Getwd()
+	xlsxFile, err = OpenFile(wd_path + "/../../../../../testdocs/testfile.xlsx")
 	c.Assert(err, IsNil)
 	sheetCount := len(xlsxFile.Sheets)
 	c.Assert(sheetCount, Equals, 3)
@@ -314,7 +326,8 @@ func (l *FileSuite) TestCreateSheet(c *C) {
 	var err error
 	var sheet *Sheet
 	var row *Row
-	xlsxFile, err = OpenFile("./testdocs/testfile.xlsx")
+	wd_path, _ := os.Getwd()
+	xlsxFile, err = OpenFile(wd_path + "/../../../../../testdocs/testfile.xlsx")
 	c.Assert(err, IsNil)
 	c.Assert(xlsxFile, NotNil)
 	sheetLen := len(xlsxFile.Sheets)
@@ -379,7 +392,8 @@ func (l *FileSuite) TestAppendSheetWithDuplicateName(c *C) {
 // Test that we can read & create a 31 rune sheet name
 func (l *FileSuite) TestMaxSheetNameLength(c *C) {
 	// Open a genuine xlsx created by Microsoft Excel 2007
-	xlsxFile, err := OpenFile("./testdocs/max_sheet_name_length.xlsx")
+	wd_path, _ := os.Getwd()
+	xlsxFile, err := OpenFile(wd_path + "/../../../../../testdocs/max_sheet_name_length.xlsx")
 	c.Assert(err, IsNil)
 	c.Assert(xlsxFile, NotNil)
 	c.Assert(xlsxFile.Sheets[0].Name, Equals, "αααααβββββγγγγγδδδδδεεεεεζζζζζη")
@@ -882,19 +896,22 @@ type SliceReaderSuite struct{}
 var _ = Suite(&SliceReaderSuite{})
 
 func (s *SliceReaderSuite) TestFileToSlice(c *C) {
-	output, err := FileToSlice("./testdocs/testfile.xlsx")
+	wd_path, _ := os.Getwd()
+	output, err := FileToSlice(wd_path + "/../../../../../testdocs/testfile.xlsx")
 	c.Assert(err, IsNil)
 	fileToSliceCheckOutput(c, output)
 }
 
 func (s *SliceReaderSuite) TestFileToSliceMissingCol(c *C) {
 	// Test xlsx file with the A column removed
-	_, err := FileToSlice("./testdocs/testFileToSlice.xlsx")
+	wd_path, _ := os.Getwd()
+	_, err := FileToSlice(wd_path + "/../../../../../testdocs/testFileToSlice.xlsx")
 	c.Assert(err, IsNil)
 }
 
 func (s *SliceReaderSuite) TestFileObjToSlice(c *C) {
-	f, err := OpenFile("./testdocs/testfile.xlsx")
+	wd_path, _ := os.Getwd()
+	f, err := OpenFile(wd_path + "/../../../../../testdocs/testfile.xlsx")
 	output, err := f.ToSlice()
 	c.Assert(err, IsNil)
 	fileToSliceCheckOutput(c, output)
@@ -914,12 +931,13 @@ func fileToSliceCheckOutput(c *C, output [][][]string) {
 }
 
 func (s *SliceReaderSuite) TestFileToSliceUnmerged(c *C) {
-	output, err := FileToSliceUnmerged("./testdocs/testfile.xlsx")
+	wd_path, _ := os.Getwd()
+	output, err := FileToSliceUnmerged(wd_path + "/../../../../../testdocs/testfile.xlsx")
 	c.Assert(err, IsNil)
 	fileToSliceCheckOutput(c, output)
 
 	// merged cells
-	output, err = FileToSliceUnmerged("./testdocs/merged_cells.xlsx")
+	output, err = FileToSliceUnmerged(wd_path + "/../../../../../testdocs/merged_cells.xlsx")
 	c.Assert(err, IsNil)
 	c.Assert(output[0][6][2], Equals, "Happy New Year!")
 	c.Assert(output[0][6][1], Equals, "Happy New Year!")
@@ -931,7 +949,8 @@ func (l *FileSuite) TestReadWorkbookWithTypes(c *C) {
 	var xlsxFile *File
 	var err error
 
-	xlsxFile, err = OpenFile("./testdocs/testcelltypes.xlsx")
+	wd_path, _ := os.Getwd()
+	xlsxFile, err = OpenFile(wd_path + "/../../../../../testdocs/testcelltypes.xlsx")
 	c.Assert(err, IsNil)
 	c.Assert(len(xlsxFile.Sheets), Equals, 1)
 	sheet := xlsxFile.Sheet["Sheet1"]
@@ -985,7 +1004,8 @@ func (l *FileSuite) TestReadWorkbookWithTypes(c *C) {
 }
 
 func (s *SliceReaderSuite) TestFileWithEmptyRows(c *C) {
-	f, err := OpenFile("./testdocs/empty_rows.xlsx")
+	wd_path, _ := os.Getwd()
+	f, err := OpenFile(wd_path + "/../../../../../testdocs/empty_rows.xlsx")
 	c.Assert(err, IsNil)
 	sheet, ok := f.Sheet["EmptyRows"]
 	c.Assert(ok, Equals, true)
@@ -1003,7 +1023,8 @@ func (s *SliceReaderSuite) TestFileWithEmptyRows(c *C) {
 }
 
 func (s *SliceReaderSuite) TestFileWithEmptyCols(c *C) {
-	f, err := OpenFile("./testdocs/empty_rows.xlsx")
+	wd_path, _ := os.Getwd()
+	f, err := OpenFile(wd_path + "/../../../../../testdocs/empty_rows.xlsx")
 	c.Assert(err, IsNil)
 	sheet, ok := f.Sheet["EmptyCols"]
 	c.Assert(ok, Equals, true)
diff --git a/lib_test.go b/lib_test.go
index 9d8f5db..8357843 100644
--- a/lib_test.go
+++ b/lib_test.go
@@ -16,14 +16,16 @@ var _ = Suite(&LibSuite{})
 
 // Attempting to open a file without workbook.xml.rels returns an error.
 func (l *LibSuite) TestReadZipReaderWithFileWithNoWorkbookRels(c *C) {
-	_, err := OpenFile("./testdocs/badfile_noWorkbookRels.xlsx")
+	wd_path, _ := os.Getwd()
+	_, err := OpenFile(wd_path + "/../../../../../testdocs/badfile_noWorkbookRels.xlsx")
 	c.Assert(err, NotNil)
 	c.Assert(err.Error(), Equals, "xl/_rels/workbook.xml.rels not found in input xlsx.")
 }
 
 // Attempting to open a file with no worksheets returns an error.
 func (l *LibSuite) TestReadZipReaderWithFileWithNoWorksheets(c *C) {
-	_, err := OpenFile("./testdocs/badfile_noWorksheets.xlsx")
+	wd_path, _ := os.Getwd()
+	_, err := OpenFile(wd_path + "/../../../../../testdocs/badfile_noWorksheets.xlsx")
 	c.Assert(err, NotNil)
 	c.Assert(err.Error(), Equals, "Input xlsx contains no worksheets.")
 }
@@ -33,7 +35,8 @@ func (l *LibSuite) TestReadWithInlineStrings(c *C) {
 	var xlsxFile *File
 	var err error
 
-	xlsxFile, err = OpenFile("./testdocs/inlineStrings.xlsx")
+	wd_path, _ := os.Getwd()
+	xlsxFile, err = OpenFile(wd_path + "/../../../../../testdocs/inlineStrings.xlsx")
 	c.Assert(err, IsNil)
 	sheet := xlsxFile.Sheets[0]
 	r1 := sheet.Rows[0]
@@ -57,7 +60,8 @@ func (l *LibSuite) TestReadWorkbookRelationsFromZipFileWithFunnyNames(c *C) {
 	var xlsxFile *File
 	var err error
 
-	xlsxFile, err = OpenFile("./testdocs/testrels.xlsx")
+	wd_path, _ := os.Getwd()
+	xlsxFile, err = OpenFile(wd_path + "/../../../../../testdocs/testrels.xlsx")
 	c.Assert(err, IsNil)
 	bob := xlsxFile.Sheet["Bob"]
 	row1 := bob.Rows[0]
@@ -1340,16 +1344,18 @@ func (l *LibSuite) TestRowNotOverwrittenWhenFollowedByEmptyRow(c *C) {
 
 // This was a specific issue raised by a user.
 func (l *LibSuite) TestRoundTripFileWithNoSheetCols(c *C) {
-	originalXlFile, err := OpenFile("testdocs/original.xlsx")
+	wd_path, _ := os.Getwd()
+	originalXlFile, err := OpenFile(wd_path + "/../../../../../testdocs/original.xlsx")
 	c.Assert(err, IsNil)
-	originalXlFile.Save("testdocs/after_write.xlsx")
-	_, err = OpenFile("testdocs/after_write.xlsx")
+	originalXlFile.Save(wd_path + "/../../../../../testdocs/after_write.xlsx")
+	_, err = OpenFile(wd_path + "/../../../../../testdocs/after_write.xlsx")
 	c.Assert(err, IsNil)
-	os.Remove("testdocs/after_write.xlsx")
+	os.Remove(wd_path + "/../../../../../testdocs/after_write.xlsx")
 }
 
 func (l *LibSuite) TestReadRestEmptyRowsFromSheet(c *C) {
-	originalXlFile, err := OpenFile("testdocs/empty_rows_in_the_rest.xlsx")
+	wd_path, _ := os.Getwd()
+	originalXlFile, err := OpenFile(wd_path + "/../../../../../testdocs/empty_rows_in_the_rest.xlsx")
 	c.Assert(err, IsNil)
 	for _, sheet := range originalXlFile.Sheets {
 		for _, row := range sheet.Rows {
-- 
2.20.1

