f-29: watchdog: add specific config #29
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
a1df88a1f2
commit
2ce7ebafe7
3 changed files with 78 additions and 0 deletions
|
|
@ -81,3 +81,68 @@ database:
|
|||
t.Errorf("attendu %q, obtenu %q", "/opt/two/data", cfg.Database.Path)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadConfig_WatchdogDefauts(t *testing.T) {
|
||||
path := writeYAML(t, "")
|
||||
cfg, err := LoadConfig(path)
|
||||
if err != nil {
|
||||
t.Fatalf("LoadConfig a échoué : %v", err)
|
||||
}
|
||||
if cfg.Watchdog.Enabled {
|
||||
t.Error("watchdog.enabled devrait être false par défaut")
|
||||
}
|
||||
if cfg.Watchdog.IntervalSeconds != 60 {
|
||||
t.Errorf("watchdog.interval_seconds attendu 60, obtenu %d", cfg.Watchdog.IntervalSeconds)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadConfig_WatchdogValeursExplicites(t *testing.T) {
|
||||
path := writeYAML(t, `
|
||||
watchdog:
|
||||
enabled: true
|
||||
interval_seconds: 30
|
||||
`)
|
||||
cfg, err := LoadConfig(path)
|
||||
if err != nil {
|
||||
t.Fatalf("LoadConfig a échoué : %v", err)
|
||||
}
|
||||
if !cfg.Watchdog.Enabled {
|
||||
t.Error("watchdog.enabled attendu true")
|
||||
}
|
||||
if cfg.Watchdog.IntervalSeconds != 30 {
|
||||
t.Errorf("watchdog.interval_seconds attendu 30, obtenu %d", cfg.Watchdog.IntervalSeconds)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadConfig_WatchdogActiveSansIntervalle(t *testing.T) {
|
||||
path := writeYAML(t, `
|
||||
watchdog:
|
||||
enabled: true
|
||||
`)
|
||||
cfg, err := LoadConfig(path)
|
||||
if err != nil {
|
||||
t.Fatalf("LoadConfig a échoué : %v", err)
|
||||
}
|
||||
if !cfg.Watchdog.Enabled {
|
||||
t.Error("watchdog.enabled attendu true")
|
||||
}
|
||||
if cfg.Watchdog.IntervalSeconds != 60 {
|
||||
t.Errorf("watchdog.interval_seconds attendu 60 (défaut viper), obtenu %d", cfg.Watchdog.IntervalSeconds)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadConfig_ExempleFourniEstValide(t *testing.T) {
|
||||
cfg, err := LoadConfig("../../../conf/agent/config.exemple.yml")
|
||||
if err != nil {
|
||||
t.Fatalf("config.exemple.yml illisible : %v", err)
|
||||
}
|
||||
if !cfg.Watchdog.Enabled {
|
||||
t.Error("config.exemple.yml devrait activer le watchdog")
|
||||
}
|
||||
if cfg.Watchdog.IntervalSeconds != 60 {
|
||||
t.Errorf("config.exemple.yml : interval_seconds attendu 60, obtenu %d", cfg.Watchdog.IntervalSeconds)
|
||||
}
|
||||
if cfg.QEMU.QMPDir == "" {
|
||||
t.Error("config.exemple.yml devrait définir qemu.qmp_dir")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue