feat: add shell login option (#75)

Closes #72
This commit is contained in:
Paolo Ricciuti
2026-07-30 22:45:23 +07:00
committed by GitHub
parent 37182f7212
commit 2573ad73b4
10 changed files with 103 additions and 12 deletions
+18 -3
View File
@@ -3,8 +3,10 @@ package root
import (
"bytes"
"os"
"path/filepath"
"strings"
"testing"
"github.com/versenilvis/iris/internal/config"
)
func TestConfigCommands(t *testing.T) {
@@ -14,14 +16,27 @@ func TestConfigCommands(t *testing.T) {
}
defer os.RemoveAll(tmpDir)
// UserConfigDir follows HOME on macOS and XDG_CONFIG_HOME on Unix.
// Override both so the command cannot read or write the user's real config.
t.Setenv("HOME", tmpDir)
t.Setenv("XDG_CONFIG_HOME", tmpDir)
ConfigInitCmd.Run(ConfigInitCmd, []string{})
configPath := filepath.Join(tmpDir, "iris", "config.toml")
if _, err := os.Stat(configPath); err != nil {
configPath, err := config.ConfigPath()
if err != nil {
t.Fatalf("failed to get config path: %v", err)
}
if _, statErr := os.Stat(configPath); statErr != nil {
t.Errorf("expected config file to be created at %s, but it was not", configPath)
}
content, err := os.ReadFile(configPath)
if err != nil {
t.Fatalf("failed to read config file: %v", err)
}
if !strings.Contains(string(content), "shell-login = false") {
t.Error("expected initialized config to include shell-login = false")
}
buf := new(bytes.Buffer)
ConfigShowCmd.SetOut(buf)