Files
iris-context/root/config_cmd_test.go
T
VERSE 1e04949242 refactor: better project structure (#35)
This project is starting to grow, and I've seen flaws in the initial
project structure design
I think I'll restructure the entire project directory for better
scalability and also cleaner
2026-07-11 16:15:05 +07:00

33 lines
729 B
Go

package root
import (
"bytes"
"os"
"path/filepath"
"testing"
)
func TestConfigCommands(t *testing.T) {
tmpDir, err := os.MkdirTemp("", "iris-config-cmd-test")
if err != nil {
t.Fatalf("failed to create temp dir: %v", err)
}
defer os.RemoveAll(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 {
t.Errorf("expected config file to be created at %s, but it was not", configPath)
}
buf := new(bytes.Buffer)
ConfigShowCmd.SetOut(buf)
ConfigShowCmd.Run(ConfigShowCmd, []string{})
if buf.Len() == 0 {
t.Errorf("expected show command to output configuration")
}
}