agedit/pkg/env/env_test.go

31 lines
556 B
Go
Raw Normal View History

2024-03-11 20:23:36 -04:00
package env
import (
"os"
"testing"
)
var (
editors = []string{"hx", "nano", "vi", "vim", "nvim", "micro", "emacs", "ed"}
)
func clearEnvForNow() {
for _, item := range []string{"EDITOR", "VISUAL"} {
os.Setenv(item, "")
}
}
func TestEditorFromEnv(t *testing.T) {
for _, item := range []string{"EDITOR", "VISUAL"} {
clearEnvForNow()
for _, editor := range editors {
if err := os.Setenv(item, editor); err != nil {
t.Fatal(err)
}
if got := GetEditor(); got != editor {
t.Fatal("got", got, "but wanted", editor)
}
}
}
}