summaryrefslogtreecommitdiff
path: root/picture_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'picture_test.go')
-rw-r--r--picture_test.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/picture_test.go b/picture_test.go
index 518713f..2b39ed8 100644
--- a/picture_test.go
+++ b/picture_test.go
@@ -6,6 +6,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
+ "strings"
"testing"
"github.com/stretchr/testify/assert"
@@ -146,3 +147,20 @@ func TestAddDrawingPicture(t *testing.T) {
f := NewFile()
assert.EqualError(t, f.addDrawingPicture("sheet1", "", "A", "", 0, 0, 0, 0, nil), `cannot convert cell "A" to coordinates: invalid cell name "A"`)
}
+
+func TestAddPictureFromBytes(t *testing.T) {
+ f := NewFile()
+ imgFile, err := ioutil.ReadFile("logo.png")
+ if err != nil {
+ t.Error("Unable to load logo for test")
+ }
+ f.AddPictureFromBytes("Sheet1", fmt.Sprint("A", 1), "", "logo", ".png", imgFile)
+ f.AddPictureFromBytes("Sheet1", fmt.Sprint("A", 50), "", "logo", ".png", imgFile)
+ imageCount := 0
+ for fileName := range f.XLSX {
+ if strings.Contains(fileName, "media/image") {
+ imageCount++
+ }
+ }
+ assert.Equal(t, 1, imageCount, "Duplicate image should only be stored once.")
+}