aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Lemon <matt@matthewlemon.com>2020-08-06 14:11:15 +0100
committerMatthew Lemon <matt@matthewlemon.com>2020-08-06 14:11:15 +0100
commit0bb7c2b3ac9f8bbc148c3fbfca59fe9f600babf6 (patch)
tree7af5a9ab1b7f377635ac25d2938d4f4545276f83
parent8a4c985d232cdf21ec054d8c0d2fa42f581082dd (diff)
tests passing but only with the help of a hack to solve DD/MM/YY
-rw-r--r--pkg/datamaps/db.go4
-rw-r--r--pkg/datamaps/testdata/test_template.xlsmbin9194 -> 9390 bytes
-rw-r--r--pkg/datamaps/testdata/test_template.xlsxbin9397 -> 9389 bytes
-rw-r--r--pkg/datamaps/writer_test.go7
4 files changed, 8 insertions, 3 deletions
diff --git a/pkg/datamaps/db.go b/pkg/datamaps/db.go
index d95bfd7..2a63a11 100644
--- a/pkg/datamaps/db.go
+++ b/pkg/datamaps/db.go
@@ -243,6 +243,10 @@ func importXLSXtoDB(dmName string, returnName string, file string, db *sql.DB) e
}
defer insertStmt.Close()
+ // Hack to fix bug in Libreoffice numformats for dates
+ if cellData.NumFmt == "DD/MM/YY" {
+ cellData.SetFormat("dd/mm/yy")
+ }
fValue, err := cellData.FormattedValue()
if err != nil {
return err
diff --git a/pkg/datamaps/testdata/test_template.xlsm b/pkg/datamaps/testdata/test_template.xlsm
index 725805d..7681c04 100644
--- a/pkg/datamaps/testdata/test_template.xlsm
+++ b/pkg/datamaps/testdata/test_template.xlsm
Binary files differ
diff --git a/pkg/datamaps/testdata/test_template.xlsx b/pkg/datamaps/testdata/test_template.xlsx
index 52f6360..4b46dbb 100644
--- a/pkg/datamaps/testdata/test_template.xlsx
+++ b/pkg/datamaps/testdata/test_template.xlsx
Binary files differ
diff --git a/pkg/datamaps/writer_test.go b/pkg/datamaps/writer_test.go
index e16ce10..e168f8d 100644
--- a/pkg/datamaps/writer_test.go
+++ b/pkg/datamaps/writer_test.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
"os/exec"
+ "path/filepath"
"strings"
"testing"
@@ -38,9 +39,9 @@ func TestWriteMaster(t *testing.T) {
XLSXPath: "./testdata/",
}
- // defer func() {
- // os.Remove(filepath.Join(opts.MasterOutPutPath, "master.xlsx"))
- // }()
+ defer func() {
+ os.Remove(filepath.Join(opts.MasterOutPutPath, "master.xlsx"))
+ }()
if err := DatamapToDB(&opts); err != nil {
t.Fatalf("Unable to write datamap to database file because %v.", err)