Пример #1
0
func checkPart(t *testing.T, errPrefix string, expected string, st types.Storage, idx *types.ObjectIndex) {
	part, err := st.GetPart(idx)
	if err != nil {
		t.Errorf("%s - %s", errPrefix, err)
		return
	}
	got, err := ioutil.ReadAll(part)
	if err != nil {
		t.Errorf("%s - %s", errPrefix, err)
		return
	}
	if string(got) != expected {
		t.Errorf("%s expected \n`%s`\n, got \n`%s`", errPrefix, expected, string(got))
	}
}
Пример #2
0
func checkPartIsMissing(t *testing.T, errPrefix string, st types.Storage, idx *types.ObjectIndex) {
	part, err := st.GetPart(idx)
	if os.IsNotExist(err) {
		return // all is fine
	} else if err != nil {
		t.Errorf("%s - was expected to be os.ErrNotExist but it was %s", errPrefix, err)
		return
	}
	t.Errorf("%s - was expected to be erronous but it wasn't", errPrefix)
	got, err := ioutil.ReadAll(part)
	if err != nil {
		t.Errorf("%s - %s", errPrefix, err)
		return
	}
	t.Errorf("%s has contents of `%s`", errPrefix, got)
}
Пример #3
0
// A single goroutine running this function is created for every storage.
// types.CacheAlgorithms will send to the com channel files which they wish to be removed
// from the storage.
func (a *Application) cacheToStorageCommunicator(stor types.Storage,
	com chan types.ObjectIndex) {
	for oi := range com {
		stor.DiscardIndex(oi)
	}
}