fix(libreoffice): start the long-running listener on the first conversion (fixes #420)

This commit is contained in:
Julien Neuhart
2022-03-21 16:39:52 +01:00
parent 27018fa8e2
commit 64ea2b6d3b
4 changed files with 158 additions and 116 deletions

View File

@@ -196,55 +196,7 @@ func TestUNO_Validate(t *testing.T) {
}
func TestUNO_Start(t *testing.T) {
tests := []struct {
name string
mod UNO
expectStartErr bool
}{
{
name: "nominal behavior",
mod: UNO{
libreOfficeRestartThreshold: 10,
listener: listenerMock{
startMock: func(logger *zap.Logger) error {
return nil
},
},
},
},
{
name: "no long-running LibreOffice listener",
mod: UNO{
libreOfficeRestartThreshold: 0,
},
},
{
name: "start error",
mod: UNO{
libreOfficeRestartThreshold: 10,
listener: listenerMock{
startMock: func(logger *zap.Logger) error {
return errors.New("foo")
},
},
},
expectStartErr: true,
},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
err := tc.mod.Start()
if tc.expectStartErr && err == nil {
t.Errorf("expected mod.Start() error, but got none")
}
if !tc.expectStartErr && err != nil {
t.Errorf("expected no error from mod.Start(), but got: %v", err)
}
})
}
}
func TestUNO_StartupMessage(t *testing.T) {
@@ -254,11 +206,11 @@ func TestUNO_StartupMessage(t *testing.T) {
expectMessage string
}{
{
name: "long-running LibreOffice listener started",
name: "long-running LibreOffice listener ready to start",
mod: UNO{
libreOfficeRestartThreshold: 10,
},
expectMessage: "long-running LibreOffice listener started",
expectMessage: "long-running LibreOffice listener ready to start",
},
{
name: "long-running LibreOffice listener disabled",
@@ -549,11 +501,6 @@ func TestUNO_PDF(t *testing.T) {
mod.libreOfficeRestartThreshold,
)
err := mod.Start()
if err != nil {
t.Fatalf("expected no error from mod.Start(), but got: %v", err)
}
return mod
}(),
ctx: context.Background(),