Fix wrong graphdb refs paths purging
Signed-off-by: Antonio Murdaca <me@runcom.ninja>
This commit is contained in:
parent
504425a9ff
commit
b12971703d
2 changed files with 53 additions and 5 deletions
|
@ -472,8 +472,8 @@ func TestPurgeId(t *testing.T) {
|
|||
|
||||
db.Set("/webapp", "1")
|
||||
|
||||
if db.Refs("1") != 1 {
|
||||
t.Fatal("Expect reference count to be 1")
|
||||
if c := db.Refs("1"); c != 1 {
|
||||
t.Fatalf("Expect reference count to be 1, got %d", c)
|
||||
}
|
||||
|
||||
db.Set("/db", "2")
|
||||
|
@ -484,7 +484,45 @@ func TestPurgeId(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
if count != 2 {
|
||||
t.Fatal("Expected 2 references to be removed")
|
||||
t.Fatalf("Expected 2 references to be removed, got %d", count)
|
||||
}
|
||||
}
|
||||
|
||||
// Regression test https://github.com/docker/docker/issues/12334
|
||||
func TestPurgeIdRefPaths(t *testing.T) {
|
||||
db, dbpath := newTestDb(t)
|
||||
defer destroyTestDb(dbpath)
|
||||
|
||||
db.Set("/webapp", "1")
|
||||
db.Set("/db", "2")
|
||||
|
||||
db.Set("/db/webapp", "1")
|
||||
|
||||
if c := db.Refs("1"); c != 2 {
|
||||
t.Fatalf("Expected 2 reference for webapp, got %d", c)
|
||||
}
|
||||
if c := db.Refs("2"); c != 1 {
|
||||
t.Fatalf("Expected 1 reference for db, got %d", c)
|
||||
}
|
||||
|
||||
if rp := db.RefPaths("2"); len(rp) != 1 {
|
||||
t.Fatalf("Expected 1 reference path for db, got %d", len(rp))
|
||||
}
|
||||
|
||||
count, err := db.Purge("2")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if count != 2 {
|
||||
t.Fatalf("Expected 2 rows to be removed, got %d", count)
|
||||
}
|
||||
|
||||
if c := db.Refs("2"); c != 0 {
|
||||
t.Fatalf("Expected 0 reference for db, got %d", c)
|
||||
}
|
||||
if c := db.Refs("1"); c != 1 {
|
||||
t.Fatalf("Expected 1 reference for webapp, got %d", c)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue