glow/editor/editor_test.go
Carlos Alexandro Becker 8b5468468a
fix: improve editor handling (#449)
* 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>
2023-01-24 14:51:11 -03:00

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)
}
})
}
}