mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-08-13 19:02:15 +01:00
* new feature: users are now able to provide more file types to convert by adding entries in their configuration file * removing README blueprint: was not working correctly * improving code coverage of config package
39 lines
894 B
Go
39 lines
894 B
Go
package file
|
|
|
|
import (
|
|
"bytes"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/thecodingmachine/gotenberg/app/config"
|
|
)
|
|
|
|
func load(configurationFilePath string) {
|
|
config.Reset()
|
|
path, _ := filepath.Abs(configurationFilePath)
|
|
config.ParseFile(path)
|
|
}
|
|
|
|
func TestNewFile(t *testing.T) {
|
|
load("../../../_tests/configurations/gotenberg.yml")
|
|
|
|
workingDir := "test"
|
|
os.Mkdir(workingDir, 0666)
|
|
|
|
// case 1: uses a wrong file name.
|
|
if _, err := NewFile(workingDir, new(bytes.Buffer), "file.yml"); err == nil {
|
|
t.Error("File should not have been instantiated with an empty buffer")
|
|
}
|
|
|
|
// case 2: uses a file name.
|
|
filePath, _ := filepath.Abs("../../../_tests/file.pdf")
|
|
r, _ := os.Open(filePath)
|
|
defer r.Close()
|
|
if _, err := NewFile(workingDir, r, "file.pdf"); err != nil {
|
|
t.Errorf("File should have been instantiated using a reader of '%s'", filePath)
|
|
}
|
|
|
|
os.RemoveAll(workingDir)
|
|
}
|