mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-08-14 19:32:15 +01:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0e8385a5a7 | ||
|
|
afd3763d96 |
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2023 Julien Neuhart
|
Copyright (c) 2024 Julien Neuhart
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ func FormDataChromiumScreenshotOptions(ctx *api.Context) (*api.FormData, Screens
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if value != "png" && value != "jpeg" && value != "" {
|
if value != "png" && value != "jpeg" && value != "webp" {
|
||||||
return fmt.Errorf("wrong value, expected either 'png', 'jpeg' or 'webp'")
|
return fmt.Errorf("wrong value, expected either 'png', 'jpeg' or 'webp'")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -209,7 +209,24 @@ func TestFormDataChromiumScreenshotOptions(t *testing.T) {
|
|||||||
}(),
|
}(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
scenario: "valid format form field",
|
scenario: "valid png format form field",
|
||||||
|
ctx: func() *api.ContextMock {
|
||||||
|
ctx := &api.ContextMock{Context: new(api.Context)}
|
||||||
|
ctx.SetValues(map[string][]string{
|
||||||
|
"format": {
|
||||||
|
"png",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
return ctx
|
||||||
|
}(),
|
||||||
|
expectedOptions: func() ScreenshotOptions {
|
||||||
|
options := DefaultScreenshotOptions()
|
||||||
|
options.Format = "png"
|
||||||
|
return options
|
||||||
|
}(),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
scenario: "valid jpeg format form field",
|
||||||
ctx: func() *api.ContextMock {
|
ctx: func() *api.ContextMock {
|
||||||
ctx := &api.ContextMock{Context: new(api.Context)}
|
ctx := &api.ContextMock{Context: new(api.Context)}
|
||||||
ctx.SetValues(map[string][]string{
|
ctx.SetValues(map[string][]string{
|
||||||
@@ -225,6 +242,23 @@ func TestFormDataChromiumScreenshotOptions(t *testing.T) {
|
|||||||
return options
|
return options
|
||||||
}(),
|
}(),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
scenario: "valid webp format form field",
|
||||||
|
ctx: func() *api.ContextMock {
|
||||||
|
ctx := &api.ContextMock{Context: new(api.Context)}
|
||||||
|
ctx.SetValues(map[string][]string{
|
||||||
|
"format": {
|
||||||
|
"webp",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
return ctx
|
||||||
|
}(),
|
||||||
|
expectedOptions: func() ScreenshotOptions {
|
||||||
|
options := DefaultScreenshotOptions()
|
||||||
|
options.Format = "webp"
|
||||||
|
return options
|
||||||
|
}(),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
scenario: "invalid quality form field (not an integer)",
|
scenario: "invalid quality form field (not an integer)",
|
||||||
ctx: func() *api.ContextMock {
|
ctx: func() *api.ContextMock {
|
||||||
|
|||||||
Reference in New Issue
Block a user