示例#1
0
func TestGC_EmptyRun(t *testing.T) {
	bs := &MockGCBlobStore{
		bs:        []string{"x", "y", "z"},
		removedbs: []string{},
	}
	idb := &MockFscker{
		usedbs: []string{"x", "y", "z"},
	}

	// vvv should not panic.
	if err := gc.GC(context.TODO(), bs, idb, false); err != nil {
		t.Errorf("GC err: %v", err)
	}
	if len(bs.removedbs) > 0 {
		t.Errorf("GC removed unexpected blobs: %v", bs.removedbs)
	}
}
示例#2
0
func TestGC_Basic(t *testing.T) {
	bs := &MockGCBlobStore{
		bs:        []string{"a", "b", "x", "y", "z", "META_INODEDB_SNAPSHOT"},
		removedbs: []string{},
	}
	idb := &MockFscker{
		usedbs: []string{"x", "y", "z"},
	}

	if err := gc.GC(context.TODO(), bs, idb, false); err != nil {
		t.Errorf("GC err: %v", err)
	}

	if !reflect.DeepEqual([]string{"a", "b"}, bs.removedbs) {
		t.Errorf("GC removed unexpected blobs: %v", bs.removedbs)
	}
}