mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-08-17 04:32:15 +01:00
fix: chromium memory leaks (#705)
This commit is contained in:
@@ -20,7 +20,7 @@ func TestMultiPDFEngines_Merge(t *testing.T) {
|
||||
{
|
||||
name: "nominal behavior",
|
||||
engine: newMultiPDFEngines(
|
||||
gotenberg.PDFEngineMock{
|
||||
&gotenberg.PDFEngineMock{
|
||||
MergeMock: func(ctx context.Context, logger *zap.Logger, inputPaths []string, outputPath string) error {
|
||||
return nil
|
||||
},
|
||||
@@ -31,12 +31,12 @@ func TestMultiPDFEngines_Merge(t *testing.T) {
|
||||
{
|
||||
name: "at least one engine does not return an error",
|
||||
engine: newMultiPDFEngines(
|
||||
gotenberg.PDFEngineMock{
|
||||
&gotenberg.PDFEngineMock{
|
||||
MergeMock: func(ctx context.Context, logger *zap.Logger, inputPaths []string, outputPath string) error {
|
||||
return errors.New("foo")
|
||||
},
|
||||
},
|
||||
gotenberg.PDFEngineMock{
|
||||
&gotenberg.PDFEngineMock{
|
||||
MergeMock: func(ctx context.Context, logger *zap.Logger, inputPaths []string, outputPath string) error {
|
||||
return nil
|
||||
},
|
||||
@@ -47,12 +47,12 @@ func TestMultiPDFEngines_Merge(t *testing.T) {
|
||||
{
|
||||
name: "all engines return an error",
|
||||
engine: newMultiPDFEngines(
|
||||
gotenberg.PDFEngineMock{
|
||||
&gotenberg.PDFEngineMock{
|
||||
MergeMock: func(ctx context.Context, logger *zap.Logger, inputPaths []string, outputPath string) error {
|
||||
return errors.New("foo")
|
||||
},
|
||||
},
|
||||
gotenberg.PDFEngineMock{
|
||||
&gotenberg.PDFEngineMock{
|
||||
MergeMock: func(ctx context.Context, logger *zap.Logger, inputPaths []string, outputPath string) error {
|
||||
return errors.New("foo")
|
||||
},
|
||||
@@ -64,7 +64,7 @@ func TestMultiPDFEngines_Merge(t *testing.T) {
|
||||
{
|
||||
name: "context expired",
|
||||
engine: newMultiPDFEngines(
|
||||
gotenberg.PDFEngineMock{
|
||||
&gotenberg.PDFEngineMock{
|
||||
MergeMock: func(ctx context.Context, logger *zap.Logger, inputPaths []string, outputPath string) error {
|
||||
return nil
|
||||
},
|
||||
@@ -105,7 +105,7 @@ func TestMultiPDFEngines_Convert(t *testing.T) {
|
||||
{
|
||||
name: "nominal behavior",
|
||||
engine: newMultiPDFEngines(
|
||||
gotenberg.PDFEngineMock{
|
||||
&gotenberg.PDFEngineMock{
|
||||
ConvertMock: func(ctx context.Context, logger *zap.Logger, format, inputPath, outputPath string) error {
|
||||
return nil
|
||||
},
|
||||
@@ -116,12 +116,12 @@ func TestMultiPDFEngines_Convert(t *testing.T) {
|
||||
{
|
||||
name: "at least one engine does not return an error",
|
||||
engine: newMultiPDFEngines(
|
||||
gotenberg.PDFEngineMock{
|
||||
&gotenberg.PDFEngineMock{
|
||||
ConvertMock: func(ctx context.Context, logger *zap.Logger, format, inputPath, outputPath string) error {
|
||||
return errors.New("foo")
|
||||
},
|
||||
},
|
||||
gotenberg.PDFEngineMock{
|
||||
&gotenberg.PDFEngineMock{
|
||||
ConvertMock: func(ctx context.Context, logger *zap.Logger, format, inputPath, outputPath string) error {
|
||||
return nil
|
||||
},
|
||||
@@ -132,12 +132,12 @@ func TestMultiPDFEngines_Convert(t *testing.T) {
|
||||
{
|
||||
name: "all engines return an error",
|
||||
engine: newMultiPDFEngines(
|
||||
gotenberg.PDFEngineMock{
|
||||
&gotenberg.PDFEngineMock{
|
||||
ConvertMock: func(ctx context.Context, logger *zap.Logger, format, inputPath, outputPath string) error {
|
||||
return errors.New("foo")
|
||||
},
|
||||
},
|
||||
gotenberg.PDFEngineMock{
|
||||
&gotenberg.PDFEngineMock{
|
||||
ConvertMock: func(ctx context.Context, logger *zap.Logger, format, inputPath, outputPath string) error {
|
||||
return errors.New("foo")
|
||||
},
|
||||
@@ -149,7 +149,7 @@ func TestMultiPDFEngines_Convert(t *testing.T) {
|
||||
{
|
||||
name: "context expired",
|
||||
engine: newMultiPDFEngines(
|
||||
gotenberg.PDFEngineMock{
|
||||
&gotenberg.PDFEngineMock{
|
||||
ConvertMock: func(ctx context.Context, logger *zap.Logger, format, inputPath, outputPath string) error {
|
||||
return nil
|
||||
},
|
||||
|
||||
@@ -32,7 +32,7 @@ func TestPDFEngines_Provision(t *testing.T) {
|
||||
{
|
||||
name: "no selection from user",
|
||||
ctx: func() *gotenberg.Context {
|
||||
provider := struct {
|
||||
provider := &struct {
|
||||
gotenberg.ModuleMock
|
||||
gotenberg.LoggerProviderMock
|
||||
}{}
|
||||
@@ -45,7 +45,7 @@ func TestPDFEngines_Provision(t *testing.T) {
|
||||
return zap.NewNop(), nil
|
||||
}
|
||||
|
||||
engine := struct {
|
||||
engine := &struct {
|
||||
gotenberg.ModuleMock
|
||||
gotenberg.ValidatorMock
|
||||
gotenberg.PDFEngineMock
|
||||
@@ -72,7 +72,7 @@ func TestPDFEngines_Provision(t *testing.T) {
|
||||
{
|
||||
name: "selection from user",
|
||||
ctx: func() *gotenberg.Context {
|
||||
provider := struct {
|
||||
provider := &struct {
|
||||
gotenberg.ModuleMock
|
||||
gotenberg.LoggerProviderMock
|
||||
}{}
|
||||
@@ -85,7 +85,7 @@ func TestPDFEngines_Provision(t *testing.T) {
|
||||
return zap.NewNop(), nil
|
||||
}
|
||||
|
||||
engine1 := struct {
|
||||
engine1 := &struct {
|
||||
gotenberg.ModuleMock
|
||||
gotenberg.ValidatorMock
|
||||
gotenberg.PDFEngineMock
|
||||
@@ -97,7 +97,7 @@ func TestPDFEngines_Provision(t *testing.T) {
|
||||
return nil
|
||||
}
|
||||
|
||||
engine2 := struct {
|
||||
engine2 := &struct {
|
||||
gotenberg.ModuleMock
|
||||
gotenberg.ValidatorMock
|
||||
gotenberg.PDFEngineMock
|
||||
@@ -131,7 +131,7 @@ func TestPDFEngines_Provision(t *testing.T) {
|
||||
{
|
||||
name: "user select deprecated unoconv-pdfengine",
|
||||
ctx: func() *gotenberg.Context {
|
||||
provider := struct {
|
||||
provider := &struct {
|
||||
gotenberg.ModuleMock
|
||||
gotenberg.LoggerProviderMock
|
||||
}{}
|
||||
@@ -144,7 +144,7 @@ func TestPDFEngines_Provision(t *testing.T) {
|
||||
return zap.NewNop(), nil
|
||||
}
|
||||
|
||||
engine := struct {
|
||||
engine := &struct {
|
||||
gotenberg.ModuleMock
|
||||
gotenberg.ValidatorMock
|
||||
gotenberg.PDFEngineMock
|
||||
@@ -189,7 +189,7 @@ func TestPDFEngines_Provision(t *testing.T) {
|
||||
{
|
||||
name: "no logger from logger provider",
|
||||
ctx: func() *gotenberg.Context {
|
||||
provider := struct {
|
||||
provider := &struct {
|
||||
gotenberg.ModuleMock
|
||||
gotenberg.LoggerProviderMock
|
||||
}{}
|
||||
@@ -216,7 +216,7 @@ func TestPDFEngines_Provision(t *testing.T) {
|
||||
{
|
||||
name: "no valid PDF engines",
|
||||
ctx: func() *gotenberg.Context {
|
||||
provider := struct {
|
||||
provider := &struct {
|
||||
gotenberg.ModuleMock
|
||||
gotenberg.LoggerProviderMock
|
||||
}{}
|
||||
@@ -229,7 +229,7 @@ func TestPDFEngines_Provision(t *testing.T) {
|
||||
return zap.NewNop(), nil
|
||||
}
|
||||
|
||||
engine := struct {
|
||||
engine := &struct {
|
||||
gotenberg.ModuleMock
|
||||
gotenberg.ValidatorMock
|
||||
gotenberg.PDFEngineMock
|
||||
@@ -292,7 +292,7 @@ func TestPDFEngines_Validate(t *testing.T) {
|
||||
name: "existing PDF engine",
|
||||
names: []string{"foo"},
|
||||
engines: func() []gotenberg.PDFEngine {
|
||||
engine := struct {
|
||||
engine := &struct {
|
||||
gotenberg.ModuleMock
|
||||
gotenberg.PDFEngineMock
|
||||
}{}
|
||||
@@ -309,7 +309,7 @@ func TestPDFEngines_Validate(t *testing.T) {
|
||||
name: "non-existing bar PDF engine",
|
||||
names: []string{"foo", "bar", "baz"},
|
||||
engines: func() []gotenberg.PDFEngine {
|
||||
engine1 := struct {
|
||||
engine1 := &struct {
|
||||
gotenberg.ModuleMock
|
||||
gotenberg.PDFEngineMock
|
||||
}{}
|
||||
@@ -317,7 +317,7 @@ func TestPDFEngines_Validate(t *testing.T) {
|
||||
return gotenberg.ModuleDescriptor{ID: "foo", New: func() gotenberg.Module { return engine1 }}
|
||||
}
|
||||
|
||||
engine2 := struct {
|
||||
engine2 := &struct {
|
||||
gotenberg.ModuleMock
|
||||
gotenberg.PDFEngineMock
|
||||
}{}
|
||||
@@ -377,7 +377,7 @@ func TestPDFEngines_PDFEngine(t *testing.T) {
|
||||
mod := PDFEngines{
|
||||
names: []string{"foo", "bar"},
|
||||
engines: func() []gotenberg.PDFEngine {
|
||||
engine1 := struct {
|
||||
engine1 := &struct {
|
||||
gotenberg.ModuleMock
|
||||
gotenberg.PDFEngineMock
|
||||
}{}
|
||||
@@ -385,7 +385,7 @@ func TestPDFEngines_PDFEngine(t *testing.T) {
|
||||
return gotenberg.ModuleDescriptor{ID: "foo", New: func() gotenberg.Module { return engine1 }}
|
||||
}
|
||||
|
||||
engine2 := struct {
|
||||
engine2 := &struct {
|
||||
gotenberg.ModuleMock
|
||||
gotenberg.PDFEngineMock
|
||||
}{}
|
||||
@@ -416,7 +416,7 @@ func TestPDFEngines_Routes(t *testing.T) {
|
||||
name: "route not disabled",
|
||||
mod: PDFEngines{
|
||||
engines: []gotenberg.PDFEngine{
|
||||
gotenberg.PDFEngineMock{},
|
||||
&gotenberg.PDFEngineMock{},
|
||||
},
|
||||
},
|
||||
expectRoutesCount: 2,
|
||||
|
||||
@@ -33,7 +33,7 @@ func TestMergeHandler(t *testing.T) {
|
||||
|
||||
return ctx
|
||||
}(),
|
||||
engine: gotenberg.PDFEngineMock{
|
||||
engine: &gotenberg.PDFEngineMock{
|
||||
MergeMock: func(ctx context.Context, logger *zap.Logger, inputPaths []string, outputPath string) error {
|
||||
return nil
|
||||
},
|
||||
@@ -57,7 +57,7 @@ func TestMergeHandler(t *testing.T) {
|
||||
|
||||
return ctx
|
||||
}(),
|
||||
engine: gotenberg.PDFEngineMock{
|
||||
engine: &gotenberg.PDFEngineMock{
|
||||
MergeMock: func(ctx context.Context, logger *zap.Logger, inputPaths []string, outputPath string) error {
|
||||
return errors.New("foo")
|
||||
},
|
||||
@@ -79,7 +79,7 @@ func TestMergeHandler(t *testing.T) {
|
||||
|
||||
return ctx
|
||||
}(),
|
||||
engine: gotenberg.PDFEngineMock{
|
||||
engine: &gotenberg.PDFEngineMock{
|
||||
MergeMock: func(ctx context.Context, logger *zap.Logger, inputPaths []string, outputPath string) error {
|
||||
return nil
|
||||
},
|
||||
@@ -104,7 +104,7 @@ func TestMergeHandler(t *testing.T) {
|
||||
|
||||
return ctx
|
||||
}(),
|
||||
engine: gotenberg.PDFEngineMock{
|
||||
engine: &gotenberg.PDFEngineMock{
|
||||
MergeMock: func(ctx context.Context, logger *zap.Logger, inputPaths []string, outputPath string) error {
|
||||
return nil
|
||||
},
|
||||
@@ -129,7 +129,7 @@ func TestMergeHandler(t *testing.T) {
|
||||
|
||||
return ctx
|
||||
}(),
|
||||
engine: gotenberg.PDFEngineMock{
|
||||
engine: &gotenberg.PDFEngineMock{
|
||||
MergeMock: func(ctx context.Context, logger *zap.Logger, inputPaths []string, outputPath string) error {
|
||||
return nil
|
||||
},
|
||||
@@ -152,7 +152,7 @@ func TestMergeHandler(t *testing.T) {
|
||||
|
||||
return ctx
|
||||
}(),
|
||||
engine: gotenberg.PDFEngineMock{
|
||||
engine: &gotenberg.PDFEngineMock{
|
||||
MergeMock: func(ctx context.Context, logger *zap.Logger, inputPaths []string, outputPath string) error {
|
||||
return nil
|
||||
},
|
||||
@@ -226,7 +226,7 @@ func TestConvertHandler(t *testing.T) {
|
||||
|
||||
return ctx
|
||||
}(),
|
||||
engine: gotenberg.PDFEngineMock{
|
||||
engine: &gotenberg.PDFEngineMock{
|
||||
ConvertMock: func(ctx context.Context, logger *zap.Logger, format, inputPath, outputPath string) error {
|
||||
return nil
|
||||
},
|
||||
@@ -250,7 +250,7 @@ func TestConvertHandler(t *testing.T) {
|
||||
|
||||
return ctx
|
||||
}(),
|
||||
engine: gotenberg.PDFEngineMock{
|
||||
engine: &gotenberg.PDFEngineMock{
|
||||
ConvertMock: func(ctx context.Context, logger *zap.Logger, format, inputPath, outputPath string) error {
|
||||
return nil
|
||||
},
|
||||
@@ -302,7 +302,7 @@ func TestConvertHandler(t *testing.T) {
|
||||
|
||||
return ctx
|
||||
}(),
|
||||
engine: gotenberg.PDFEngineMock{
|
||||
engine: &gotenberg.PDFEngineMock{
|
||||
ConvertMock: func(ctx context.Context, logger *zap.Logger, format, inputPath, outputPath string) error {
|
||||
return errors.New("foo")
|
||||
},
|
||||
@@ -324,7 +324,7 @@ func TestConvertHandler(t *testing.T) {
|
||||
|
||||
return ctx
|
||||
}(),
|
||||
engine: gotenberg.PDFEngineMock{
|
||||
engine: &gotenberg.PDFEngineMock{
|
||||
ConvertMock: func(ctx context.Context, logger *zap.Logger, format, inputPath, outputPath string) error {
|
||||
return gotenberg.ErrPDFFormatNotAvailable
|
||||
},
|
||||
@@ -349,7 +349,7 @@ func TestConvertHandler(t *testing.T) {
|
||||
|
||||
return ctx
|
||||
}(),
|
||||
engine: gotenberg.PDFEngineMock{
|
||||
engine: &gotenberg.PDFEngineMock{
|
||||
ConvertMock: func(ctx context.Context, logger *zap.Logger, format, inputPath, outputPath string) error {
|
||||
return nil
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user