mirror of
https://github.com/charmbracelet/glow
synced 2025-01-18 23:14:00 +00:00
8b5468468a
* fix: improve editor handling Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com> * test: add tests Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com> Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
26 lines
561 B
Go
26 lines
561 B
Go
package editor
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
)
|
|
|
|
func TestEditor(t *testing.T) {
|
|
filename := "README.md"
|
|
for k, v := range map[string][]string{
|
|
"": {"nano", filename},
|
|
"nvim": {"nvim", filename},
|
|
"vim": {"vim", filename},
|
|
"vscode --foo": {"vscode", "--foo", filename},
|
|
"nvim -a -b": {"nvim", "-a", "-b", filename},
|
|
} {
|
|
t.Run(k, func(t *testing.T) {
|
|
t.Setenv("EDITOR", k)
|
|
cmd := Cmd("README.md")
|
|
got := cmd.Args
|
|
if !reflect.DeepEqual(got, v) {
|
|
t.Fatalf("expected %v; got %v", v, got)
|
|
}
|
|
})
|
|
}
|
|
}
|