(t *testing.T)
| 78 | } |
| 79 | |
| 80 | func TestCmdEditProjectBumpsUpdatedAt(t *testing.T) { |
| 81 | root, db := showListEditDB(t) |
| 82 | insertProject(t, db, "bigp", "Big P", filepath.Join(root, "x"), "medium") |
| 83 | if _, err := db.Exec(`UPDATE projects SET updated_at = '2020-01-01T00:00:00Z' WHERE slug = ?`, "bigp"); err != nil { |
| 84 | t.Fatal(err) |
| 85 | } |
| 86 | briefPath := filepath.Join(root, "projects", "bigp", "brief.md") |
| 87 | if err := os.MkdirAll(filepath.Dir(briefPath), 0o755); err != nil { |
| 88 | t.Fatal(err) |
| 89 | } |
| 90 | if err := os.WriteFile(briefPath, []byte("orig\n"), 0o644); err != nil { |
| 91 | t.Fatal(err) |
| 92 | } |
| 93 | script := writeFakeEditor(t, t.TempDir()) |
| 94 | os.Setenv("EDITOR", script) |
| 95 | t.Cleanup(func() { os.Unsetenv("EDITOR") }) |
| 96 | |
| 97 | if rc := cmdEdit([]string{"bigp"}); rc != 0 { |
| 98 | t.Errorf("rc=%d", rc) |
| 99 | } |
| 100 | got, err := flowdb.GetProject(db, "bigp") |
| 101 | if err != nil { |
| 102 | t.Fatal(err) |
| 103 | } |
| 104 | if got.UpdatedAt == "2020-01-01T00:00:00Z" { |
| 105 | t.Errorf("project updated_at not bumped") |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | func TestCmdEditUnknownRef(t *testing.T) { |
| 110 | _, _ = showListEditDB(t) |
nothing calls this directly
no test coverage detected