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

Function TestCmdWorkdirRemove

internal/app/workdir_test.go:124–149  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

122}
123
124func TestCmdWorkdirRemove(t *testing.T) {
125 root := setupArchiveTestEnv(t)
126 db := reopenArchiveTestDB(t, root)
127
128 p := filepath.Join(t.TempDir(), "repo")
129 if err := os.MkdirAll(p, 0o755); err != nil {
130 t.Fatal(err)
131 }
132 if rc := cmdWorkdir([]string{"add", p}); rc != 0 {
133 t.Fatalf("add rc=%d", rc)
134 }
135 if rc := cmdWorkdir([]string{"remove", p}); rc != 0 {
136 t.Fatalf("remove rc=%d", rc)
137 }
138 var count int
139 if err := db.QueryRow("SELECT COUNT(*) FROM workdirs WHERE path = ?", p).Scan(&count); err != nil {
140 t.Fatal(err)
141 }
142 if count != 0 {
143 t.Errorf("row still present after remove")
144 }
145 // Filesystem untouched.
146 if _, err := os.Stat(p); err != nil {
147 t.Errorf("directory removed from filesystem: %v", err)
148 }
149}
150
151func TestCmdWorkdirScanFindsRepos(t *testing.T) {
152 setupArchiveTestEnv(t)

Callers

nothing calls this directly

Calls 3

setupArchiveTestEnvFunction · 0.85
reopenArchiveTestDBFunction · 0.85
cmdWorkdirFunction · 0.85

Tested by

no test coverage detected