This commit is contained in:
63
backend_v1/app/jobs/download_from_alioss_test.go
Normal file
63
backend_v1/app/jobs/download_from_alioss_test.go
Normal file
@@ -0,0 +1,63 @@
|
||||
package jobs
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"quyun/v2/app/commands/testx"
|
||||
"quyun/v2/app/model"
|
||||
"quyun/v2/providers/ali"
|
||||
"quyun/v2/providers/app"
|
||||
"quyun/v2/providers/job"
|
||||
|
||||
. "github.com/riverqueue/river"
|
||||
. "github.com/smartystreets/goconvey/convey"
|
||||
"github.com/stretchr/testify/suite"
|
||||
_ "go.ipao.vip/atom"
|
||||
"go.ipao.vip/atom/contracts"
|
||||
"go.uber.org/dig"
|
||||
)
|
||||
|
||||
type DownloadFromAliOSSSuiteInjectParams struct {
|
||||
dig.In
|
||||
|
||||
Initials []contracts.Initial `group:"initials"` // nolint:structcheck
|
||||
Job *job.Job
|
||||
Oss *ali.OSSClient
|
||||
App *app.Config
|
||||
}
|
||||
|
||||
type DownloadFromAliOSSSuite struct {
|
||||
suite.Suite
|
||||
|
||||
DownloadFromAliOSSSuiteInjectParams
|
||||
}
|
||||
|
||||
func Test_DownloadFromAliOSS(t *testing.T) {
|
||||
providers := testx.Default().With(Provide, model.Provide)
|
||||
|
||||
testx.Serve(providers, t, func(p DownloadFromAliOSSSuiteInjectParams) {
|
||||
suite.Run(t, &DownloadFromAliOSSSuite{DownloadFromAliOSSSuiteInjectParams: p})
|
||||
})
|
||||
}
|
||||
|
||||
func (t *DownloadFromAliOSSSuite) Test_Work() {
|
||||
Convey("test_work", t.T(), func() {
|
||||
Convey("step 1", func() {
|
||||
job := &Job[DownloadFromAliOSS]{
|
||||
Args: DownloadFromAliOSS{
|
||||
MediaHash: "959e5310105c96e653f10b74e5bdc36b",
|
||||
},
|
||||
}
|
||||
|
||||
worker := &DownloadFromAliOSSWorker{
|
||||
oss: t.Oss,
|
||||
job: t.Job,
|
||||
app: t.App,
|
||||
}
|
||||
|
||||
err := worker.Work(context.Background(), job)
|
||||
So(err, ShouldBeNil)
|
||||
})
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user