Skip to content

🎧 Your Personal Streaming Service

fix: option to skip flags, to avoid breaking the tests

Deluancc6eacd60879
diff --git a/conf/configuration.go b/conf/configuration.go
index fd77529de..0faea17e6 100644
--- a/conf/configuration.go
+++ b/conf/configuration.go
@@ -34,8 +34,8 @@ type nd struct {
var Server = &nd{}
-func NewWithPath(path string) *multiconfig.DefaultLoader {
- loaders := []multiconfig.Loader{}
+func newWithPath(path string, skipFlags ...bool) *multiconfig.DefaultLoader {
+ var loaders []multiconfig.Loader
// Read default values defined via tag fields "default"
loaders = append(loaders, &multiconfig.TagLoader{})
@@ -55,9 +55,12 @@ func NewWithPath(path string) *multiconfig.DefaultLoader {
}
e := &multiconfig.EnvironmentLoader{}
- f := &multiconfig.FlagLoader{}
+ loaders = append(loaders, e)
+ if len(skipFlags) == 0 || !skipFlags[0] {
+ f := &multiconfig.FlagLoader{}
+ loaders = append(loaders, f)
+ }
- loaders = append(loaders, e, f)
loader := multiconfig.MultiLoader(loaders...)
d := &multiconfig.DefaultLoader{}
@@ -66,8 +69,8 @@ func NewWithPath(path string) *multiconfig.DefaultLoader {
return d
}
-func LoadFromFile(confFile string) {
- m := NewWithPath(confFile)
+func LoadFromFile(confFile string, skipFlags ...bool) {
+ m := newWithPath(confFile, skipFlags...)
err := m.Load(Server)
if err == flag.ErrHelp {
os.Exit(1)
diff --git a/tests/init_tests.go b/tests/init_tests.go
index 267bf574a..bb2474e35 100644
--- a/tests/init_tests.go
+++ b/tests/init_tests.go
@@ -23,7 +23,7 @@ func Init(t *testing.T, skipOnShort bool) {
confPath, _ := filepath.Abs(filepath.Join(appPath, "tests", "navidrome-test.toml"))
os.Chdir(appPath)
- conf.LoadFromFile(confPath)
+ conf.LoadFromFile(confPath, true)
noLog := os.Getenv("NOLOG")
if noLog != "" {