Fix locking around deleteFile (fixes #64)

This commit is contained in:
Jakob Borg
2014-02-09 23:24:55 +01:00
parent fc6eabea28
commit b6814241cc
2 changed files with 21 additions and 1 deletions

View File

@@ -275,3 +275,21 @@ func TestFileQueueThreadHandling(t *testing.T) {
t.Error("Total mismatch; %d != %d", gotTot, total)
}
}
func TestDeleteAt(t *testing.T) {
q := FileQueue{}
for i := 0; i < 4; i++ {
q.files = queuedFileList{{name: "a"}, {name: "b"}, {name: "c"}, {name: "d"}}
q.deleteAt(i)
if l := len(q.files); l != 3 {
t.Fatal("deleteAt(%d) failed; %d != 3", i, l)
}
}
q.files = queuedFileList{{name: "a"}}
q.deleteAt(0)
if l := len(q.files); l != 0 {
t.Fatal("deleteAt(only) failed; %d != 0", l)
}
}