go-common/app/admin/main/creative/service/upbfs_test.go
2019-04-22 18:49:16 +08:00

45 lines
972 B
Go

package service
import (
"context"
"fmt"
"testing"
"time"
. "github.com/smartystreets/goconvey/convey"
)
var (
c = context.TODO()
now = time.Now().Unix()
)
func TestService_Upload(t *testing.T) {
Convey("Upload should return without err", t, WithService(func(svf *Service) {
// simulate file content
str2 := "Testing File Content"
data2 := []byte(str2)
// upload to bfs
location, err := svf.Upload(c, "tName", "image/png", now, data2)
// testing
So(err, ShouldBeNil)
So(location, ShouldNotBeNil)
fmt.Println(location)
}))
}
func TestService_ParseFile(t *testing.T) {
Convey("ParseFile can get file info", t, WithService(func(svf *Service) {
// simulate file content
str2 := "Testing File Content"
data2 := []byte(str2)
// upload to bfs
fInfo, err := svf.ParseFile(c, data2)
// testing
So(err, ShouldBeNil)
So(fInfo.Size, ShouldBeGreaterThan, 0)
So(fInfo.Type, ShouldNotBeBlank)
So(fInfo.Md5, ShouldNotBeBlank)
}))
}