feat(api): add debug route

This commit is contained in:
Julien Neuhart
2025-02-04 10:20:29 +01:00
parent 740e701ad3
commit a1596f7c62
22 changed files with 628 additions and 4 deletions

View File

@@ -71,6 +71,59 @@ func TestPdfCpu_Validate(t *testing.T) {
}
}
func TestPdfCpu_Debug(t *testing.T) {
for _, tc := range []struct {
scenario string
engine *PdfCpu
expect map[string]interface{}
doNotExpect map[string]interface{}
}{
{
scenario: "cannot determine version (command error)",
engine: &PdfCpu{
binPath: "foo",
},
expect: map[string]interface{}{
"version": `exec: "foo": executable file not found in $PATH`,
},
},
{
scenario: "cannot determine version (no pdfcpu)",
engine: &PdfCpu{
binPath: "echo",
},
expect: map[string]interface{}{
"version": "Unable to determine pdfcpu version",
},
},
{
scenario: "success",
engine: &PdfCpu{
binPath: "pdfcpu",
},
doNotExpect: map[string]interface{}{
"version": "Unable to determine pdfcpu version",
},
},
} {
t.Run(tc.scenario, func(t *testing.T) {
d := tc.engine.Debug()
if tc.expect != nil {
if !reflect.DeepEqual(d, tc.expect) {
t.Errorf("expected '%v' but got '%v'", tc.expect, d)
}
}
if tc.doNotExpect != nil {
if reflect.DeepEqual(d, tc.doNotExpect) {
t.Errorf("did not expect '%v'", d)
}
}
})
}
}
func TestPdfCpu_Merge(t *testing.T) {
for _, tc := range []struct {
scenario string