package editor import ( "os" "path/filepath" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestOpenWithEditor_PlainCommand(t *testing.T) { err := OpenWithEditor("/dev/null", "true") require.NoError(t, err) } func TestOpenWithEditor_PercentS(t *testing.T) { dir := t.TempDir() path := filepath.Join(dir, "testfile") require.NoError(t, os.WriteFile(path, []byte("content"), 0600)) err := OpenWithEditor(path, "true %s") require.NoError(t, err) } func TestOpenWithEditor_QuotedPercentS(t *testing.T) { dir := t.TempDir() path := filepath.Join(dir, "testfile") require.NoError(t, os.WriteFile(path, []byte("content"), 0600)) err := OpenWithEditor(path, "true '%s'") require.NoError(t, err) } func TestOpenWithEditor_PathWithSpaces(t *testing.T) { dir := t.TempDir() path := filepath.Join(dir, "file with spaces") require.NoError(t, os.WriteFile(path, []byte("content"), 0600)) err := OpenWithEditor(path, "true %s") require.NoError(t, err) } func TestOpenWithEditor_InvalidCommand(t *testing.T) { err := OpenWithEditor("/tmp/fake", "/nonexistent/cmd") assert.Error(t, err) }