aboutsummaryrefslogtreecommitdiff
path: root/internal/editor/editor_test.go
diff options
context:
space:
mode:
authorishaan <contact@ishaan.cc>2026-07-16 13:11:08 +0530
committerishaan <contact@ishaan.cc>2026-07-16 13:11:08 +0530
commitcc11788404e68fcf7f5356bcc275f331c13fc36e (patch)
tree04be33465f497956aaf08e0ef440eb453d6d26dd /internal/editor/editor_test.go
parent006e7975455153e32893cb38196d59d20945590e (diff)
testify tests for utils, editor, and crud
Diffstat (limited to 'internal/editor/editor_test.go')
-rw-r--r--internal/editor/editor_test.go47
1 files changed, 47 insertions, 0 deletions
diff --git a/internal/editor/editor_test.go b/internal/editor/editor_test.go
new file mode 100644
index 0000000..86bc095
--- /dev/null
+++ b/internal/editor/editor_test.go
@@ -0,0 +1,47 @@
+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)
+}