MCPcopy Create free account
hub / github.com/Facets-cloud/flow / TestCmdEditProjectBumpsUpdatedAt

Function TestCmdEditProjectBumpsUpdatedAt

internal/app/edit_test.go:80–107  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

78}
79
80func 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
109func TestCmdEditUnknownRef(t *testing.T) {
110 _, _ = showListEditDB(t)

Callers

nothing calls this directly

Calls 5

GetProjectFunction · 0.92
showListEditDBFunction · 0.85
writeFakeEditorFunction · 0.85
cmdEditFunction · 0.85
insertProjectFunction · 0.70

Tested by

no test coverage detected