package medias import ( "context" "testing" "backend/pkg/path" "backend/pkg/pg" "backend/pkg/service/testx" "backend/providers/hashids" "backend/providers/postgres" "backend/providers/storage" . "github.com/smartystreets/goconvey/convey" "github.com/stretchr/testify/suite" "go.uber.org/dig" ) type ServiceInjectParams struct { dig.In Svc *Service } type ServiceTestSuite struct { suite.Suite ServiceInjectParams } func Test_DiscoverMedias(t *testing.T) { providers := testx.Default( postgres.DefaultProvider(), storage.DefaultProvider(), hashids.DefaultProvider(), ).With( Provide, ) testx.Serve(providers, t, func(params ServiceInjectParams) { suite.Run(t, &ServiceTestSuite{ServiceInjectParams: params}) }) } func (t *ServiceTestSuite) Test_getM3U8() { FocusConvey("Test_ffmpegVideoToM3U8", t.T(), func() { Convey("Bought", func() { hash := "f464a6641a60e2722e4042db8fad2813" media, err := t.Svc.GetM3U8(context.Background(), 1, pg.MediaTypeVideo, hash, true) So(err, ShouldBeNil) t.T().Logf("%+v", media) }) FocusConvey("Not Bought", func() { hash := "f464a6641a60e2722e4042db8fad2813" media, err := t.Svc.GetM3U8(context.Background(), 1, pg.MediaTypeVideo, hash, false) So(err, ShouldBeNil) t.T().Logf("%+v", media) }) }) } func (t *ServiceTestSuite) Test_getMediaByHash() { Convey("Test_getMediaByHash", t.T(), func() { name, ext := path.SplitNameExt("0.ts") So(name, ShouldEqual, "0") So(ext, ShouldEqual, "ts") }) }