writeFakeEditor writes an executable script into dir that appends the text "edited by test" to any file path passed as its first argument. Returns the script path. Skips the test on Windows.
(t *testing.T, dir string)
| 13 | // text "edited by test" to any file path passed as its first argument. |
| 14 | // Returns the script path. Skips the test on Windows. |
| 15 | func writeFakeEditor(t *testing.T, dir string) string { |
| 16 | t.Helper() |
| 17 | if runtime.GOOS == "windows" { |
| 18 | t.Skip("fake editor relies on a POSIX shell script") |
| 19 | } |
| 20 | path := filepath.Join(dir, "fake-editor.sh") |
| 21 | content := `#!/bin/sh |
| 22 | printf '\nedited by test\n' >> "$1" |
| 23 | ` |
| 24 | if err := os.WriteFile(path, []byte(content), 0o755); err != nil { |
| 25 | t.Fatalf("write fake editor: %v", err) |
| 26 | } |
| 27 | return path |
| 28 | } |
| 29 | |
| 30 | func TestCmdEditTaskBumpsUpdatedAt(t *testing.T) { |
| 31 | root, db := showListEditDB(t) |
no outgoing calls
no test coverage detected