package config import ( "path/filepath" "strings" "testing" "yetano.dev/yetano/core/paths" ) func TestConfigExplain(t *testing.T) { root := t.TempDir() writeFile(t, filepath.Join(root, "home", "test", ".config", "yet", "yet.yaml"), "port: 8080\n") env := map[string]string{"HOME": "/home/test"} r := mustResolver(t, yetApp(), WithEnvironment(env), WithPathsOptions(paths.WithPlatform("linux"), paths.WithRoot(root)), WithWorkdirPath(filepath.Join(root, "workdir")), ) ex, err := r.Explain() if err != nil { t.Fatalf("Explain: %v", err) } if ex.Selected == "" { t.Fatal("Explain().Selected is empty, want the existing user layer") } if want := filepath.Join(root, "home", "test", ".config", "yet", "yet.yaml"); ex.Selected != want { t.Errorf("Explain().Selected = %q, want %q", ex.Selected, want) } if len(ex.Paths.Paths) == 0 { t.Error("Explain().Paths.Paths is empty, want core/paths categories included") } text := ex.String() if !strings.Contains(text, "Configuration layers:") || !strings.Contains(text, "Selected:") { t.Errorf("Explain().String() missing expected sections:\n%s", text) } }