mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-08-11 18:02:14 +01:00
improving lock mechanism for office conversion: now check if context has timeout when trying to acquire the lock + office printer test
This commit is contained in:
35
test/internalpkg/printertest/printertest.go
Normal file
35
test/internalpkg/printertest/printertest.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package printertest
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/thecodingmachine/gotenberg/internal/pkg/xrand"
|
||||
)
|
||||
|
||||
const testdataDirectoryPath string = "/gotenberg/tests/test/testdata"
|
||||
|
||||
// GenerateDestination simply generates
|
||||
// a path for a resulting PDF file.
|
||||
func GenerateDestination() string {
|
||||
return fmt.Sprintf("/tmp/%s.pdf", xrand.Get())
|
||||
}
|
||||
|
||||
// OfficeFpaths return the paths
|
||||
// of the Office documents used in tests.
|
||||
func OfficeFpaths(t *testing.T) []string {
|
||||
return []string{
|
||||
fpath(t, "office", "document.docx"),
|
||||
fpath(t, "office", "document.rtf"),
|
||||
fpath(t, "office", "document.txt"),
|
||||
}
|
||||
}
|
||||
|
||||
func fpath(t *testing.T, kind, filename string) string {
|
||||
require.NotEmpty(t, kind)
|
||||
require.NotEmpty(t, filename)
|
||||
fpath := fmt.Sprintf("%s/%s/%s", testdataDirectoryPath, kind, filename)
|
||||
require.FileExists(t, fpath)
|
||||
return fpath
|
||||
}
|
||||
Reference in New Issue
Block a user