(t *testing.T)
| 122 | } |
| 123 | |
| 124 | func 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 | |
| 151 | func TestCmdWorkdirScanFindsRepos(t *testing.T) { |
| 152 | setupArchiveTestEnv(t) |
nothing calls this directly
no test coverage detected