Exemplo n.º 1
0
// Test that err invalid index is returned
func testInvalidIndex(tc testContext, folder store.Folder, max uint64) {
	if err := folder.InsertMessage(0, nil, 0); err != store.ErrInvalidID {
		tc.T().Error("Expected ", store.ErrInvalidID, " got ", err)
	}

	if err := folder.InsertMessage(max, nil, 0); err != store.ErrInvalidID {
		tc.T().Error("Expected ", store.ErrInvalidID, " got ", err)
	}

	if _, _, err := folder.GetMessage(0); err != store.ErrNotFound {
		tc.T().Error("Expected ", store.ErrNotFound, " got ", err)
	}

	if _, _, err := folder.GetMessage(max); err != store.ErrNotFound {
		tc.T().Error("Expected ", store.ErrNotFound, " got ", err)
	}

	if err := folder.DeleteMessage(0); err != store.ErrInvalidID {
		tc.T().Error("Expected ", store.ErrInvalidID, " got ", err)
	}

	if err := folder.DeleteMessage(max); err != store.ErrInvalidID {
		tc.T().Error("Expected ", store.ErrInvalidID, " got ", err)
	}
}
Exemplo n.º 2
0
func testDeleteMessage(tc testContext, mbox store.Folder, id uint64, note string) {
	err := mbox.DeleteMessage(id)
	if err != nil {
		tc.T().Errorf("%s, %s: For id %d got error %v", tc.Context(), note, id, err)
	}
	_, _, err = mbox.GetMessage(id)
	if err == nil {
		tc.T().Errorf("%s, %s: for id %d expected ErrNotFound got nil", tc.Context(), note, id)
	} else if err != store.ErrNotFound {
		tc.T().Errorf("%s, %s: For id %d got error %v", tc.Context(), note, id, err)
	}
}