Files
gotenberg/app/config/parser_test.go
Julien Neuhart 4997b73bac new feature: users are now able to provide more file types to convert by adding entries in their configuration file (#3)
* 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
2018-05-03 17:18:55 +02:00

63 lines
2.2 KiB
Go

package config
import (
"path/filepath"
"testing"
)
func load(configurationFilePath string) error {
Reset()
return ParseFile(configurationFilePath)
}
func TestParseFile(t *testing.T) {
var path string
// case 1: uses an empty configuration file path.
if err := load(""); err == nil {
t.Error("Configuration should not have been populated by using an empty configuration file path")
}
// case 2: uses a broken configuration file.
path, _ = filepath.Abs("../../_tests/configurations/broken-gotenberg.yml")
if err := load(path); err == nil {
t.Errorf("Configuration should not have been populated with '%s'", path)
}
// case 3: uses a configuration file with a wrong logging level.
path, _ = filepath.Abs("../../_tests/configurations/wrong-logging-level-gotenberg.yml")
if err := load(path); err == nil {
t.Errorf("Configuration should not have been populated with '%s'", path)
}
// case 4: uses a configuration file with a wrong logging formatter.
path, _ = filepath.Abs("../../_tests/configurations/wrong-logging-formatter-gotenberg.yml")
if err := load(path); err == nil {
t.Errorf("Configuration should not have been populated with '%s'", path)
}
// case 5: uses a configuration file with a wrong merge command template.
path, _ = filepath.Abs("../../_tests/configurations/wrong-merge-command-template-gotenberg.yml")
if err := load(path); err == nil {
t.Errorf("Configuration should not have been populated with '%s'", path)
}
// case 6: uses a configuration file with a wrong command template.
path, _ = filepath.Abs("../../_tests/configurations/wrong-command-template-gotenberg.yml")
if err := load(path); err == nil {
t.Errorf("Configuration should not have been populated with '%s'", path)
}
// case 7: uses a configuration file with a duplicate command.
path, _ = filepath.Abs("../../_tests/configurations/duplicate-command-gotenberg.yml")
if err := load(path); err == nil {
t.Errorf("Configuration should not have been populated with '%s'", path)
}
// case 8: uses a correct configuration file.
path, _ = filepath.Abs("../../_tests/configurations/gotenberg.yml")
if err := load(path); err != nil {
t.Errorf("Configuration should have been populated with '%s'", path)
}
}