54 lines
1.6 KiB
Go
54 lines
1.6 KiB
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
// TestLoadFailsOnMissingFile runs one orchestration or CLI step.
|
|
// Signature: TestLoadFailsOnMissingFile(t *testing.T).
|
|
// Why: covers file-read failure handling for config load path.
|
|
func TestLoadFailsOnMissingFile(t *testing.T) {
|
|
if _, err := Load(filepath.Join(t.TempDir(), "missing.yaml")); err == nil {
|
|
t.Fatalf("expected missing file error")
|
|
}
|
|
}
|
|
|
|
// TestLoadFailsOnBadYAML runs one orchestration or CLI step.
|
|
// Signature: TestLoadFailsOnBadYAML(t *testing.T).
|
|
// Why: covers YAML decode failure handling for config load path.
|
|
func TestLoadFailsOnBadYAML(t *testing.T) {
|
|
cfgPath := filepath.Join(t.TempDir(), "ananke.yaml")
|
|
if err := os.WriteFile(cfgPath, []byte(":\n- invalid"), 0o644); err != nil {
|
|
t.Fatalf("write bad config: %v", err)
|
|
}
|
|
if _, err := Load(cfgPath); err == nil {
|
|
t.Fatalf("expected decode error")
|
|
}
|
|
}
|
|
|
|
// TestLoadFailsValidationOnBrokenValues runs one orchestration or CLI step.
|
|
// Signature: TestLoadFailsValidationOnBrokenValues(t *testing.T).
|
|
// Why: covers Load->Validate error propagation.
|
|
func TestLoadFailsValidationOnBrokenValues(t *testing.T) {
|
|
cfgPath := filepath.Join(t.TempDir(), "ananke.yaml")
|
|
raw := `
|
|
control_planes: [titan-0a]
|
|
expected_flux_branch: main
|
|
expected_flux_source_url: ssh://git@scm.bstein.dev:2242/bstein/titan-iac.git
|
|
iac_repo_path: /opt/titan-iac
|
|
startup:
|
|
service_checklist:
|
|
- name: x
|
|
url: https://ok.example
|
|
timeout_seconds: 0
|
|
`
|
|
if err := os.WriteFile(cfgPath, []byte(raw), 0o644); err != nil {
|
|
t.Fatalf("write config: %v", err)
|
|
}
|
|
if _, err := Load(cfgPath); err == nil {
|
|
t.Fatalf("expected validation failure")
|
|
}
|
|
}
|