diff --git a/common/coreproperties.go b/common/coreproperties.go index 8e4f3720..96dd75c1 100644 --- a/common/coreproperties.go +++ b/common/coreproperties.go @@ -163,5 +163,5 @@ func (c CoreProperties) SetDescription(s string) { if c.x.Description == nil { c.x.Description = &gooxml.XSDAny{XMLName: xml.Name{Local: "dc:description"}} } - c.x.Title.Data = []byte(s) + c.x.Description.Data = []byte(s) } diff --git a/common/coreproperties_test.go b/common/coreproperties_test.go index 99fe10ff..2549b7f1 100644 --- a/common/coreproperties_test.go +++ b/common/coreproperties_test.go @@ -34,6 +34,75 @@ func TestMarshalCoreProperties(t *testing.T) { testhelper.CompareGoldenXML(t, "core.xml", got.Bytes()) } +func TestCorePropertiesSettersStrings(t *testing.T) { + cp := common.NewCoreProperties() + exp := "Foo" + + if got := cp.Author(); got != "" { + t.Errorf("expected empty author, got %s", got) + } + if got := cp.Title(); got != "" { + t.Errorf("expected empty title, got %s", got) + } + if got := cp.Description(); got != "" { + t.Errorf("expected empty description, got %s", got) + } + if got := cp.Category(); got != "" { + t.Errorf("expected empty category, got %s", got) + } + if got := cp.ContentStatus(); got != "" { + t.Errorf("expected empty contentStatus, got %s", got) + } + if got := cp.LastModifiedBy(); got != "" { + t.Errorf("expected empty lastModifiedBy, got %s", got) + } + cp.SetAuthor(exp) + if got := cp.Author(); got != exp { + t.Errorf("expected author=%s, got %s", exp, got) + } + cp.SetTitle(exp) + if got := cp.Title(); got != exp { + t.Errorf("expected title=%s, got %s", exp, got) + } + cp.SetDescription(exp) + if got := cp.Description(); got != exp { + t.Errorf("expected description=%s, got %s", exp, got) + } + cp.SetCategory(exp) + if got := cp.Category(); got != exp { + t.Errorf("expected category=%s, got %s", exp, got) + } + cp.SetContentStatus(exp) + if got := cp.ContentStatus(); got != exp { + t.Errorf("expected contentStatus=%s, got %s", exp, got) + } + cp.SetLastModifiedBy(exp) + if got := cp.LastModifiedBy(); got != exp { + t.Errorf("expected lastModifiedBy=%s, got %s", exp, got) + } +} + +func TestCorePropertiesSettersDates(t *testing.T) { + cp := common.NewCoreProperties() + exp := time.Date(2017, 1, 2, 3, 4, 5, 0, time.UTC) + if !cp.Created().IsZero() { + t.Errorf("expected zero created time, got %v", exp) + } + if !cp.Modified().IsZero() { + t.Errorf("expected zero Modified time, got %v", exp) + } + + cp.SetCreated(exp) + if got := cp.Created(); got != exp { + t.Errorf("expected created =%v, got %v", exp, got) + } + + cp.SetModified(exp) + if got := cp.Modified(); got != exp { + t.Errorf("expected modified =%v, got %v", exp, got) + } +} + func ExampleCoreProperties() { doc, _ := document.Open("document.docx") cp := doc.CoreProperties diff --git a/document/testdata/header-footer-multiple.docx b/document/testdata/header-footer-multiple.docx index 1c67f3f8..ef450f1b 100644 Binary files a/document/testdata/header-footer-multiple.docx and b/document/testdata/header-footer-multiple.docx differ diff --git a/document/testdata/simple-1.docx b/document/testdata/simple-1.docx index 6d4183a5..2fc5ee57 100644 Binary files a/document/testdata/simple-1.docx and b/document/testdata/simple-1.docx differ diff --git a/spreadsheet/testdata/simple-1.xlsx b/spreadsheet/testdata/simple-1.xlsx index 4acf81fd..fcb8f202 100644 Binary files a/spreadsheet/testdata/simple-1.xlsx and b/spreadsheet/testdata/simple-1.xlsx differ diff --git a/test-coverage.sh b/test-coverage.sh index f9802459..23c605f7 100755 --- a/test-coverage.sh +++ b/test-coverage.sh @@ -1,6 +1,6 @@ #!/bin/bash PKG=baliance.com/gooxml -ALLPKGS=`go list $PKG/...` +ALLPKGS=`go list $PKG/... | grep -iv schema` cd $GOPATH/src/$PKG echo "Prebuilding"