rename: rebrand to mire
This commit is contained in:
+13
-13
@@ -27,11 +27,11 @@ type Config struct {
|
||||
}
|
||||
|
||||
type tomlConfig struct {
|
||||
Miro tomlMiroConfig `toml:"miro"`
|
||||
Mire tomlMireConfig `toml:"mire"`
|
||||
Sandbox map[string]string `toml:"sandbox"`
|
||||
}
|
||||
|
||||
type tomlMiroConfig struct {
|
||||
type tomlMireConfig struct {
|
||||
TestDir string `toml:"test_dir"`
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ func DefaultSandboxConfig() map[string]string {
|
||||
return cloneSandbox(requiredSandboxDefaults)
|
||||
}
|
||||
|
||||
// ReadConfig reads miro.toml.
|
||||
// ReadConfig reads mire.toml.
|
||||
func ReadConfig(path string) (Config, error) {
|
||||
var raw tomlConfig
|
||||
|
||||
@@ -50,14 +50,14 @@ func ReadConfig(path string) (Config, error) {
|
||||
}
|
||||
return Config{}, fmt.Errorf("failed to read %s: %v", path, err)
|
||||
}
|
||||
if !meta.IsDefined("miro") {
|
||||
return Config{}, fmt.Errorf("failed to read %s: missing [miro] config", path)
|
||||
if !meta.IsDefined("mire") {
|
||||
return Config{}, fmt.Errorf("failed to read %s: missing [mire] config", path)
|
||||
}
|
||||
if !meta.IsDefined("miro", "test_dir") {
|
||||
return Config{}, fmt.Errorf("failed to read %s: missing required miro.test_dir", path)
|
||||
if !meta.IsDefined("mire", "test_dir") {
|
||||
return Config{}, fmt.Errorf("failed to read %s: missing required mire.test_dir", path)
|
||||
}
|
||||
if raw.Miro.TestDir == "" {
|
||||
return Config{}, fmt.Errorf("failed to read %s: empty miro.test_dir", path)
|
||||
if raw.Mire.TestDir == "" {
|
||||
return Config{}, fmt.Errorf("failed to read %s: empty mire.test_dir", path)
|
||||
}
|
||||
if !meta.IsDefined("sandbox") {
|
||||
return Config{}, fmt.Errorf("failed to read %s: missing [sandbox] config", path)
|
||||
@@ -69,15 +69,15 @@ func ReadConfig(path string) (Config, error) {
|
||||
}
|
||||
|
||||
return Config{
|
||||
TestDir: raw.Miro.TestDir,
|
||||
TestDir: raw.Mire.TestDir,
|
||||
Sandbox: sandbox,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// WriteConfig writes miro.toml.
|
||||
// WriteConfig writes mire.toml.
|
||||
func WriteConfig(path string, cfg Config) error {
|
||||
if cfg.TestDir == "" {
|
||||
return errors.New("empty miro.test_dir")
|
||||
return errors.New("empty mire.test_dir")
|
||||
}
|
||||
sandbox, err := validateSandbox(path, cfg.Sandbox)
|
||||
if err != nil {
|
||||
@@ -85,7 +85,7 @@ func WriteConfig(path string, cfg Config) error {
|
||||
}
|
||||
|
||||
var buf bytes.Buffer
|
||||
fmt.Fprintf(&buf, "[miro]\n test_dir = %q\n\n[sandbox]\n", cfg.TestDir)
|
||||
fmt.Fprintf(&buf, "[mire]\n test_dir = %q\n\n[sandbox]\n", cfg.TestDir)
|
||||
|
||||
keys := make([]string, 0, len(sandbox))
|
||||
for key := range sandbox {
|
||||
|
||||
@@ -19,7 +19,7 @@ func TestReadConfig(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
name: "with test dir and sandbox",
|
||||
content: "[miro]\ntest_dir = \"custom/suite\"\n\n[sandbox]\nvisible_home = \"/home/test\"\nkey_word = \"value\"\n",
|
||||
content: "[mire]\ntest_dir = \"custom/suite\"\n\n[sandbox]\nvisible_home = \"/home/test\"\nkey_word = \"value\"\n",
|
||||
wantDir: "custom/suite",
|
||||
wantSandbox: map[string]string{
|
||||
"visible_home": "/home/test",
|
||||
@@ -29,51 +29,51 @@ func TestReadConfig(t *testing.T) {
|
||||
{
|
||||
name: "legacy top level key",
|
||||
content: "test_dir = \"custom/suite\"\n",
|
||||
wantErr: "missing [miro] config",
|
||||
wantErr: "missing [mire] config",
|
||||
},
|
||||
{
|
||||
name: "without miro table",
|
||||
name: "without mire table",
|
||||
content: "",
|
||||
wantErr: "missing [miro] config",
|
||||
wantErr: "missing [mire] config",
|
||||
},
|
||||
{
|
||||
name: "without test dir",
|
||||
content: "[miro]\n",
|
||||
wantErr: "missing required miro.test_dir",
|
||||
content: "[mire]\n",
|
||||
wantErr: "missing required mire.test_dir",
|
||||
},
|
||||
{
|
||||
name: "empty test dir",
|
||||
content: "[miro]\ntest_dir = \"\"\n",
|
||||
wantErr: "empty miro.test_dir",
|
||||
content: "[mire]\ntest_dir = \"\"\n",
|
||||
wantErr: "empty mire.test_dir",
|
||||
},
|
||||
{
|
||||
name: "without sandbox table",
|
||||
content: "[miro]\ntest_dir = \"custom/suite\"\n",
|
||||
content: "[mire]\ntest_dir = \"custom/suite\"\n",
|
||||
wantErr: "missing [sandbox] config",
|
||||
},
|
||||
{
|
||||
name: "without required visible home",
|
||||
content: "[miro]\ntest_dir = \"custom/suite\"\n\n[sandbox]\n",
|
||||
content: "[mire]\ntest_dir = \"custom/suite\"\n\n[sandbox]\n",
|
||||
wantErr: "missing required sandbox.visible_home",
|
||||
},
|
||||
{
|
||||
name: "empty required visible home",
|
||||
content: "[miro]\ntest_dir = \"custom/suite\"\n\n[sandbox]\nvisible_home = \"\"\n",
|
||||
content: "[mire]\ntest_dir = \"custom/suite\"\n\n[sandbox]\nvisible_home = \"\"\n",
|
||||
wantErr: "empty sandbox.visible_home",
|
||||
},
|
||||
{
|
||||
name: "relative visible home",
|
||||
content: "[miro]\ntest_dir = \"custom/suite\"\n\n[sandbox]\nvisible_home = \"home/test\"\n",
|
||||
content: "[mire]\ntest_dir = \"custom/suite\"\n\n[sandbox]\nvisible_home = \"home/test\"\n",
|
||||
wantErr: "sandbox.visible_home must be an absolute path",
|
||||
},
|
||||
{
|
||||
name: "invalid sandbox key",
|
||||
content: "[miro]\ntest_dir = \"custom/suite\"\n\n[sandbox]\nvisible_home = \"/home/test\"\nKeyWord = \"value\"\n",
|
||||
content: "[mire]\ntest_dir = \"custom/suite\"\n\n[sandbox]\nvisible_home = \"/home/test\"\nKeyWord = \"value\"\n",
|
||||
wantErr: "invalid sandbox key",
|
||||
},
|
||||
{
|
||||
name: "invalid toml",
|
||||
content: "[miro]\ntest_dir = [\n",
|
||||
content: "[mire]\ntest_dir = [\n",
|
||||
wantErr: "failed to read",
|
||||
},
|
||||
{
|
||||
@@ -84,7 +84,7 @@ func TestReadConfig(t *testing.T) {
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "miro.toml")
|
||||
path := filepath.Join(t.TempDir(), "mire.toml")
|
||||
if !tt.wantMissing {
|
||||
if err := os.WriteFile(path, []byte(tt.content), 0o644); err != nil {
|
||||
t.Fatalf("WriteFile() error = %v", err)
|
||||
@@ -126,7 +126,7 @@ func TestReadConfig(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestWriteConfig(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "miro.toml")
|
||||
path := filepath.Join(t.TempDir(), "mire.toml")
|
||||
|
||||
if err := WriteConfig(path, Config{
|
||||
TestDir: "e2e",
|
||||
@@ -143,26 +143,26 @@ func TestWriteConfig(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("ReadFile() error = %v", err)
|
||||
}
|
||||
want := "[miro]\n test_dir = \"e2e\"\n\n[sandbox]\n alpha_key = \"a\"\n visible_home = \"/home/test\"\n zulu_key = \"z\"\n"
|
||||
want := "[mire]\n test_dir = \"e2e\"\n\n[sandbox]\n alpha_key = \"a\"\n visible_home = \"/home/test\"\n zulu_key = \"z\"\n"
|
||||
if string(got) != want {
|
||||
t.Fatalf("config = %q, want %q", string(got), want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWriteConfigEmptyTestDirFails(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "miro.toml")
|
||||
path := filepath.Join(t.TempDir(), "mire.toml")
|
||||
|
||||
err := WriteConfig(path, Config{})
|
||||
if err == nil {
|
||||
t.Fatal("WriteConfig() error = nil, want error")
|
||||
}
|
||||
if err.Error() != "empty miro.test_dir" {
|
||||
t.Fatalf("WriteConfig() error = %q, want %q", err.Error(), "empty miro.test_dir")
|
||||
if err.Error() != "empty mire.test_dir" {
|
||||
t.Fatalf("WriteConfig() error = %q, want %q", err.Error(), "empty mire.test_dir")
|
||||
}
|
||||
}
|
||||
|
||||
func TestWriteConfigMissingRequiredSandboxFails(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "miro.toml")
|
||||
path := filepath.Join(t.TempDir(), "mire.toml")
|
||||
|
||||
err := WriteConfig(path, Config{
|
||||
TestDir: "e2e",
|
||||
|
||||
Reference in New Issue
Block a user