示例#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)
}