fix: make miro testdir resolution explicit based on config

This commit is contained in:
2026-03-18 12:48:09 +00:00
parent 3949ee98bc
commit 666219edbf
8 changed files with 342 additions and 187 deletions
+33 -1
View File
@@ -1,6 +1,38 @@
package miro
// Init is the current no-op initializer placeholder.
import (
"errors"
"fmt"
"os"
"path/filepath"
miroconfig "miro/internal/config"
)
const defaultTestDir = "e2e"
// Init creates the default config when missing and leaves valid config untouched.
func Init() error {
root, err := currentProjectRoot()
if err != nil {
return err
}
configPath := filepath.Join(root, "miro.toml")
if _, err := os.Stat(configPath); err == nil {
if _, err := miroconfig.ReadConfig(configPath); err != nil {
return err
}
return nil
} else if !errors.Is(err, os.ErrNotExist) {
return fmt.Errorf("failed to check %s: %v", configPath, err)
}
if err := miroconfig.WriteConfig(configPath, miroconfig.Config{
TestDir: defaultTestDir,
}); err != nil {
return fmt.Errorf("failed to write %s: %v", configPath, err)
}
return nil
}