mirror of
https://github.com/tiennm99/keepalive.git
synced 2026-10-11 03:13:31 +00:00
fix(config): discover mounted yml config
This commit is contained in:
1 parent
9a69030179
commit
08da9dcb84
4 files changed
+68
-4
No files matched your search
@@ -1,6 +1,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
@@ -35,6 +38,39 @@ func TestKeepaliveExampleConfigParses(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestFirstExistingConfigFileFindsYMLFallback(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
ymlPath := filepath.Join(dir, "keepalive.yml")
|
||||
if err := os.WriteFile(ymlPath, []byte("services: []\n"), 0o600); err != nil {
|
||||
t.Fatalf("write config: %v", err)
|
||||
}
|
||||
|
||||
got, err := firstExistingConfigFile([]string{
|
||||
filepath.Join(dir, "keepalive.yaml"),
|
||||
ymlPath,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("firstExistingConfigFile returned error: %v", err)
|
||||
}
|
||||
if got != ymlPath {
|
||||
t.Fatalf("firstExistingConfigFile() = %q, want %q", got, ymlPath)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFirstExistingConfigFileReportsCandidates(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
_, err := firstExistingConfigFile([]string{
|
||||
filepath.Join(dir, "keepalive.yaml"),
|
||||
filepath.Join(dir, "keepalive.yml"),
|
||||
})
|
||||
if err == nil {
|
||||
t.Fatal("firstExistingConfigFile returned nil error")
|
||||
}
|
||||
if !strings.Contains(err.Error(), "keepalive.yaml") || !strings.Contains(err.Error(), "keepalive.yml") {
|
||||
t.Fatalf("error %q does not list expected candidates", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizeConfigSuffixesDuplicateGeneratedNames(t *testing.T) {
|
||||
services, err := normalizeConfig(appConfig{
|
||||
Services: []serviceFileConfig{
|
||||
|
||||
Reference in new issue
Block a user