36 lines
612 B
Go
36 lines
612 B
Go
package biz
|
|
|
|
import (
|
|
"excel_export/data"
|
|
"fmt"
|
|
"github.com/stretchr/testify/assert"
|
|
"os"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func cardBiz() *CardBiz {
|
|
db := data.Conn()
|
|
repo := data.NewCardRepo(db)
|
|
|
|
return NewCardBiz(repo, nil)
|
|
}
|
|
|
|
func TestCardBiz_Export(t *testing.T) {
|
|
biz := cardBiz()
|
|
begin := time.Date(2012, 10, 1, 0, 0, 0, 0, time.Local)
|
|
end := time.Date(2022, 12, 1, 0, 0, 0, 0, time.Local)
|
|
|
|
err := biz.Export(begin, end)
|
|
assert.Nil(t, err)
|
|
|
|
for i := 0; i <= biz.FileSize(); i++ {
|
|
fileName := fmt.Sprintf(biz.FileName(), i)
|
|
assert.FileExists(t, fileName)
|
|
|
|
//清理文件
|
|
os.Remove(fileName)
|
|
}
|
|
|
|
}
|