fix(config): discover mounted yml config

This commit is contained in:
tiennm99 committed 2026-06-28 14:05:48 +07:00
1 parent 9a69030179
commit 08da9dcb84
4 files changed
+68 -4

No files matched your search

+36
View File
@@ -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{