package lic import ( "context" "flag" "path/filepath" "testing" "go-common/app/job/main/tv/conf" "fmt" . "github.com/smartystreets/goconvey/convey" ) var ( ctx = context.Background() d *Dao xmlBody = `inputTime=20180606&sign=timer-import_BILIBILI&tId=UHZFmufgweRpWhqAzToFYMWtYuZhMKCU&xmlData=UHZFmufgweRpWhqAzToFYMWtYuZhMKCU2018-06-061ugc10100044drmhttp://i1.hdslb.com/bfs/archive/diuren.png2018-01-30bilibili11970-01-01SDBILIBILI0drmugc10114149114481970-01-0101SD00ugc10114149http://upos-hz-tvshenhe.acgvideo.com/upgcxcode/87/75/41057587/41057587-1-6.mp4SDhttp://upos-hz-tvshenhe.acgvideo.com/upgcxcode/87/75/41057587/41057587-1-6.mp4` ) func WithDao(f func(d *Dao)) func() { return func() { dir, _ := filepath.Abs("../../cmd/tv-job-test.toml") flag.Set("conf", dir) conf.Init() if d == nil { d = New(conf.Conf) } f(d) } } func TestDelEpLic(t *testing.T) { Convey("TestDao_CallRetry", t, WithDao(func(d *Dao) { res := DelEpLic("ugc", "timer-import_BILIBILI", []int{10109083, 10109084}) So(len(res), ShouldBeGreaterThan, 0) fmt.Println(res) })) } func TestDao_CallRetry(t *testing.T) { Convey("TestDao_CallRetry", t, WithDao(func(d *Dao) { res, err := d.CallRetry(ctx, d.conf.Sync.API.AddURL, xmlBody) So(err, ShouldBeNil) So(res, ShouldNotBeNil) })) } func TestDao_CallLic(t *testing.T) { Convey("TestDao_CallLic", t, WithDao(func(d *Dao) { result, err := d.callLic(ctx, d.conf.Sync.API.AddURL, xmlBody) So(err, ShouldBeNil) So(result, ShouldNotBeNil) })) }