27 lines
618 B
Go
27 lines
618 B
Go
package export
|
|
|
|
import (
|
|
"github.com/stretchr/testify/assert"
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
func TestExcelExporter_Export(t *testing.T) {
|
|
data := NewMysqlDataFetcher("aaa")
|
|
pwd, _ := os.Getwd()
|
|
file := NewExcel(pwd+"/aa-{begin}.xlsx", 5, map[string]string{"begin": "202301"})
|
|
e := NewExcelExporter(data, file)
|
|
file.Open()
|
|
err := e.Export("aa", "字段1")
|
|
file.Close()
|
|
assert.Nil(t, err)
|
|
|
|
assert.FileExists(t, pwd+"/aa-202301_0.xlsx")
|
|
assert.FileExists(t, pwd+"/aa-202301_1.xlsx")
|
|
assert.NoFileExists(t, pwd+"/aa-202301_2.xlsx")
|
|
|
|
_ = os.Remove(pwd + "/aa-202301_0.xlsx")
|
|
_ = os.Remove(pwd + "/aa-202301_1.xlsx")
|
|
|
|
}
|