diff options
| author | xuri <xuri.me@gmail.com> | 2021-07-05 00:03:56 +0800 | 
|---|---|---|
| committer | xuri <xuri.me@gmail.com> | 2021-07-05 00:03:56 +0800 | 
| commit | 544ef18a8cb9949fcb8833c6d2816783c90f3318 (patch) | |
| tree | 88bb3eaa9d92522d3b5c4eeb052210c26bc4c99f /file_test.go | |
| parent | 0e02329bedf6648259fd219642bb907bdb07fd21 (diff) | |
- Support concurrency iterate rows and columns
- Rename exported field `File.XLSX` to `File.Pkg`
- Exported error message
Diffstat (limited to 'file_test.go')
| -rw-r--r-- | file_test.go | 15 | 
1 files changed, 8 insertions, 7 deletions
| diff --git a/file_test.go b/file_test.go index dbbf75a..d86ce53 100644 --- a/file_test.go +++ b/file_test.go @@ -5,6 +5,7 @@ import (  	"bytes"  	"os"  	"strings" +	"sync"  	"testing"  	"github.com/stretchr/testify/assert" @@ -38,19 +39,19 @@ func TestWriteTo(t *testing.T) {  	{  		f := File{}  		buf := bytes.Buffer{} -		f.XLSX = make(map[string][]byte) -		f.XLSX["/d/"] = []byte("s") +		f.Pkg = sync.Map{} +		f.Pkg.Store("/d/", []byte("s"))  		_, err := f.WriteTo(bufio.NewWriter(&buf))  		assert.EqualError(t, err, "zip: write to directory") -		delete(f.XLSX, "/d/") +		f.Pkg.Delete("/d/")  	}  	// Test file path overflow  	{  		f := File{}  		buf := bytes.Buffer{} -		f.XLSX = make(map[string][]byte) +		f.Pkg = sync.Map{}  		const maxUint16 = 1<<16 - 1 -		f.XLSX[strings.Repeat("s", maxUint16+1)] = nil +		f.Pkg.Store(strings.Repeat("s", maxUint16+1), nil)  		_, err := f.WriteTo(bufio.NewWriter(&buf))  		assert.EqualError(t, err, "zip: FileHeader.Name too long")  	} @@ -58,8 +59,8 @@ func TestWriteTo(t *testing.T) {  	{  		f := File{}  		buf := bytes.Buffer{} -		f.XLSX = make(map[string][]byte) -		f.XLSX["s"] = nil +		f.Pkg = sync.Map{} +		f.Pkg.Store("s", nil)  		f.streams = make(map[string]*StreamWriter)  		file, _ := os.Open("123")  		f.streams["s"] = &StreamWriter{rawData: bufferedWriter{tmp: file}} | 
