Remove redundant store APIs for Boards: (#22968)
- getBlocksWithParent - getBlocksWithParentAndType - getBlocksWithType - getBlocksForBoard
Этот коммит содержится в:
@@ -536,66 +536,6 @@ func (mr *MockStoreMockRecorder) GetBlocksComplianceHistory(arg0 interface{}) *g
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBlocksComplianceHistory", reflect.TypeOf((*MockStore)(nil).GetBlocksComplianceHistory), arg0)
|
||||
}
|
||||
|
||||
// GetBlocksForBoard mocks base method.
|
||||
func (m *MockStore) GetBlocksForBoard(arg0 string) ([]*model0.Block, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetBlocksForBoard", arg0)
|
||||
ret0, _ := ret[0].([]*model0.Block)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetBlocksForBoard indicates an expected call of GetBlocksForBoard.
|
||||
func (mr *MockStoreMockRecorder) GetBlocksForBoard(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBlocksForBoard", reflect.TypeOf((*MockStore)(nil).GetBlocksForBoard), arg0)
|
||||
}
|
||||
|
||||
// GetBlocksWithParent mocks base method.
|
||||
func (m *MockStore) GetBlocksWithParent(arg0, arg1 string) ([]*model0.Block, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetBlocksWithParent", arg0, arg1)
|
||||
ret0, _ := ret[0].([]*model0.Block)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetBlocksWithParent indicates an expected call of GetBlocksWithParent.
|
||||
func (mr *MockStoreMockRecorder) GetBlocksWithParent(arg0, arg1 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBlocksWithParent", reflect.TypeOf((*MockStore)(nil).GetBlocksWithParent), arg0, arg1)
|
||||
}
|
||||
|
||||
// GetBlocksWithParentAndType mocks base method.
|
||||
func (m *MockStore) GetBlocksWithParentAndType(arg0, arg1, arg2 string) ([]*model0.Block, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetBlocksWithParentAndType", arg0, arg1, arg2)
|
||||
ret0, _ := ret[0].([]*model0.Block)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetBlocksWithParentAndType indicates an expected call of GetBlocksWithParentAndType.
|
||||
func (mr *MockStoreMockRecorder) GetBlocksWithParentAndType(arg0, arg1, arg2 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBlocksWithParentAndType", reflect.TypeOf((*MockStore)(nil).GetBlocksWithParentAndType), arg0, arg1, arg2)
|
||||
}
|
||||
|
||||
// GetBlocksWithType mocks base method.
|
||||
func (m *MockStore) GetBlocksWithType(arg0, arg1 string) ([]*model0.Block, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetBlocksWithType", arg0, arg1)
|
||||
ret0, _ := ret[0].([]*model0.Block)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetBlocksWithType indicates an expected call of GetBlocksWithType.
|
||||
func (mr *MockStoreMockRecorder) GetBlocksWithType(arg0, arg1 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBlocksWithType", reflect.TypeOf((*MockStore)(nil).GetBlocksWithType), arg0, arg1)
|
||||
}
|
||||
|
||||
// GetBoard mocks base method.
|
||||
func (m *MockStore) GetBoard(arg0 string) (*model0.Board, error) {
|
||||
m.ctrl.T.Helper()
|
||||
|
||||
@@ -105,23 +105,6 @@ func (s *SQLStore) getBlocks(db sq.BaseRunner, opts model.QueryBlocksOptions) ([
|
||||
return s.blocksFromRows(rows)
|
||||
}
|
||||
|
||||
func (s *SQLStore) getBlocksWithParentAndType(db sq.BaseRunner, boardID, parentID string, blockType string) ([]*model.Block, error) {
|
||||
opts := model.QueryBlocksOptions{
|
||||
BoardID: boardID,
|
||||
ParentID: parentID,
|
||||
BlockType: model.BlockType(blockType),
|
||||
}
|
||||
return s.getBlocks(db, opts)
|
||||
}
|
||||
|
||||
func (s *SQLStore) getBlocksWithParent(db sq.BaseRunner, boardID, parentID string) ([]*model.Block, error) {
|
||||
opts := model.QueryBlocksOptions{
|
||||
BoardID: boardID,
|
||||
ParentID: parentID,
|
||||
}
|
||||
return s.getBlocks(db, opts)
|
||||
}
|
||||
|
||||
func (s *SQLStore) getBlocksByIDs(db sq.BaseRunner, ids []string) ([]*model.Block, error) {
|
||||
query := s.getQueryBuilder(db).
|
||||
Select(s.blockFields("")...).
|
||||
@@ -148,14 +131,6 @@ func (s *SQLStore) getBlocksByIDs(db sq.BaseRunner, ids []string) ([]*model.Bloc
|
||||
return blocks, nil
|
||||
}
|
||||
|
||||
func (s *SQLStore) getBlocksWithType(db sq.BaseRunner, boardID, blockType string) ([]*model.Block, error) {
|
||||
opts := model.QueryBlocksOptions{
|
||||
BoardID: boardID,
|
||||
BlockType: model.BlockType(blockType),
|
||||
}
|
||||
return s.getBlocks(db, opts)
|
||||
}
|
||||
|
||||
// getSubTree2 returns blocks within 2 levels of the given blockID.
|
||||
func (s *SQLStore) getSubTree2(db sq.BaseRunner, boardID string, blockID string, opts model.QuerySubtreeOptions) ([]*model.Block, error) {
|
||||
query := s.getQueryBuilder(db).
|
||||
@@ -188,13 +163,6 @@ func (s *SQLStore) getSubTree2(db sq.BaseRunner, boardID string, blockID string,
|
||||
return s.blocksFromRows(rows)
|
||||
}
|
||||
|
||||
func (s *SQLStore) getBlocksForBoard(db sq.BaseRunner, boardID string) ([]*model.Block, error) {
|
||||
opts := model.QueryBlocksOptions{
|
||||
BoardID: boardID,
|
||||
}
|
||||
return s.getBlocks(db, opts)
|
||||
}
|
||||
|
||||
func (s *SQLStore) blocksFromRows(rows *sql.Rows) ([]*model.Block, error) {
|
||||
results := []*model.Block{}
|
||||
|
||||
|
||||
@@ -166,7 +166,7 @@ func (s *SQLStore) duplicateBoard(db sq.BaseRunner, boardID string, userID strin
|
||||
}
|
||||
|
||||
bab.Boards = []*model.Board{board}
|
||||
blocks, err := s.getBlocksForBoard(db, boardID)
|
||||
blocks, err := s.getBlocks(db, model.QueryBlocksOptions{BoardID: boardID})
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
@@ -326,26 +326,6 @@ func (s *SQLStore) GetBlocksComplianceHistory(opts model.QueryBlocksComplianceHi
|
||||
|
||||
}
|
||||
|
||||
func (s *SQLStore) GetBlocksForBoard(boardID string) ([]*model.Block, error) {
|
||||
return s.getBlocksForBoard(s.db, boardID)
|
||||
|
||||
}
|
||||
|
||||
func (s *SQLStore) GetBlocksWithParent(boardID string, parentID string) ([]*model.Block, error) {
|
||||
return s.getBlocksWithParent(s.db, boardID, parentID)
|
||||
|
||||
}
|
||||
|
||||
func (s *SQLStore) GetBlocksWithParentAndType(boardID string, parentID string, blockType string) ([]*model.Block, error) {
|
||||
return s.getBlocksWithParentAndType(s.db, boardID, parentID, blockType)
|
||||
|
||||
}
|
||||
|
||||
func (s *SQLStore) GetBlocksWithType(boardID string, blockType string) ([]*model.Block, error) {
|
||||
return s.getBlocksWithType(s.db, boardID, blockType)
|
||||
|
||||
}
|
||||
|
||||
func (s *SQLStore) GetBoard(id string) (*model.Board, error) {
|
||||
return s.getBoard(s.db, id)
|
||||
|
||||
|
||||
@@ -18,12 +18,8 @@ const CardLimitTimestampSystemKey = "card_limit_timestamp"
|
||||
// Store represents the abstraction of the data storage.
|
||||
type Store interface {
|
||||
GetBlocks(opts model.QueryBlocksOptions) ([]*model.Block, error)
|
||||
GetBlocksWithParentAndType(boardID, parentID string, blockType string) ([]*model.Block, error)
|
||||
GetBlocksWithParent(boardID, parentID string) ([]*model.Block, error)
|
||||
GetBlocksByIDs(ids []string) ([]*model.Block, error)
|
||||
GetBlocksWithType(boardID, blockType string) ([]*model.Block, error)
|
||||
GetSubTree2(boardID, blockID string, opts model.QuerySubtreeOptions) ([]*model.Block, error)
|
||||
GetBlocksForBoard(boardID string) ([]*model.Block, error)
|
||||
// @withTransaction
|
||||
InsertBlock(block *model.Block, userID string) error
|
||||
// @withTransaction
|
||||
|
||||
@@ -69,7 +69,7 @@ func testInsertBlock(t *testing.T, store store.Store) {
|
||||
userID := testUserID
|
||||
boardID := testBoardID
|
||||
|
||||
blocks, errBlocks := store.GetBlocksForBoard(boardID)
|
||||
blocks, errBlocks := store.GetBlocks(model.QueryBlocksOptions{BoardID: boardID})
|
||||
require.NoError(t, errBlocks)
|
||||
initialCount := len(blocks)
|
||||
|
||||
@@ -85,7 +85,7 @@ func testInsertBlock(t *testing.T, store store.Store) {
|
||||
err := store.InsertBlock(block, "user-id-1")
|
||||
require.NoError(t, err)
|
||||
|
||||
blocks, err := store.GetBlocksForBoard(boardID)
|
||||
blocks, err := store.GetBlocks(model.QueryBlocksOptions{BoardID: boardID})
|
||||
require.NoError(t, err)
|
||||
require.Len(t, blocks, initialCount+1)
|
||||
|
||||
@@ -105,7 +105,7 @@ func testInsertBlock(t *testing.T, store store.Store) {
|
||||
err := store.InsertBlock(block, "user-id-1")
|
||||
require.Error(t, err)
|
||||
|
||||
blocks, err := store.GetBlocksForBoard(boardID)
|
||||
blocks, err := store.GetBlocks(model.QueryBlocksOptions{BoardID: boardID})
|
||||
require.NoError(t, err)
|
||||
require.Len(t, blocks, initialCount+1)
|
||||
})
|
||||
@@ -121,7 +121,7 @@ func testInsertBlock(t *testing.T, store store.Store) {
|
||||
err := store.InsertBlock(block, "user-id-1")
|
||||
require.Error(t, err)
|
||||
|
||||
blocks, err := store.GetBlocksForBoard(boardID)
|
||||
blocks, err := store.GetBlocks(model.QueryBlocksOptions{BoardID: boardID})
|
||||
require.NoError(t, err)
|
||||
require.Len(t, blocks, initialCount+1)
|
||||
})
|
||||
@@ -204,7 +204,7 @@ func testInsertBlock(t *testing.T, store store.Store) {
|
||||
func testInsertBlocks(t *testing.T, store store.Store) {
|
||||
userID := testUserID
|
||||
|
||||
blocks, errBlocks := store.GetBlocksForBoard("id-test")
|
||||
blocks, errBlocks := store.GetBlocks(model.QueryBlocksOptions{BoardID: "id-test"})
|
||||
require.NoError(t, errBlocks)
|
||||
initialCount := len(blocks)
|
||||
|
||||
@@ -227,7 +227,7 @@ func testInsertBlocks(t *testing.T, store store.Store) {
|
||||
err := store.InsertBlocks(newBlocks, "user-id-1")
|
||||
require.Error(t, err)
|
||||
|
||||
blocks, err := store.GetBlocksForBoard("id-test")
|
||||
blocks, err := store.GetBlocks(model.QueryBlocksOptions{BoardID: "id-test"})
|
||||
require.NoError(t, err)
|
||||
// no blocks should have been inserted
|
||||
require.Len(t, blocks, initialCount)
|
||||
@@ -249,7 +249,7 @@ func testPatchBlock(t *testing.T, store store.Store) {
|
||||
err := store.InsertBlock(block, "user-id-1")
|
||||
require.NoError(t, err)
|
||||
|
||||
blocks, errBlocks := store.GetBlocksForBoard(boardID)
|
||||
blocks, errBlocks := store.GetBlocks(model.QueryBlocksOptions{BoardID: boardID})
|
||||
require.NoError(t, errBlocks)
|
||||
initialCount := len(blocks)
|
||||
|
||||
@@ -259,7 +259,7 @@ func testPatchBlock(t *testing.T, store store.Store) {
|
||||
require.ErrorAs(t, err, &nf)
|
||||
require.True(t, model.IsErrNotFound(err))
|
||||
|
||||
blocks, err := store.GetBlocksForBoard(boardID)
|
||||
blocks, err := store.GetBlocks(model.QueryBlocksOptions{BoardID: boardID})
|
||||
require.NoError(t, err)
|
||||
require.Len(t, blocks, initialCount)
|
||||
})
|
||||
@@ -272,7 +272,7 @@ func testPatchBlock(t *testing.T, store store.Store) {
|
||||
err := store.PatchBlock("id-test", blockPatch, "user-id-1")
|
||||
require.Error(t, err)
|
||||
|
||||
blocks, err := store.GetBlocksForBoard(boardID)
|
||||
blocks, err := store.GetBlocks(model.QueryBlocksOptions{BoardID: boardID})
|
||||
require.NoError(t, err)
|
||||
require.Len(t, blocks, initialCount)
|
||||
})
|
||||
@@ -452,7 +452,7 @@ var (
|
||||
|
||||
func testGetSubTree2(t *testing.T, store store.Store) {
|
||||
boardID := testBoardID
|
||||
blocks, err := store.GetBlocksForBoard(boardID)
|
||||
blocks, err := store.GetBlocks(model.QueryBlocksOptions{BoardID: boardID})
|
||||
require.NoError(t, err)
|
||||
initialCount := len(blocks)
|
||||
|
||||
@@ -460,7 +460,7 @@ func testGetSubTree2(t *testing.T, store store.Store) {
|
||||
time.Sleep(1 * time.Millisecond)
|
||||
defer DeleteBlocks(t, store, subtreeSampleBlocks, "test")
|
||||
|
||||
blocks, err = store.GetBlocksForBoard(boardID)
|
||||
blocks, err = store.GetBlocks(model.QueryBlocksOptions{BoardID: boardID})
|
||||
require.NoError(t, err)
|
||||
require.Len(t, blocks, initialCount+6)
|
||||
|
||||
@@ -492,7 +492,7 @@ func testDeleteBlock(t *testing.T, store store.Store) {
|
||||
userID := testUserID
|
||||
boardID := testBoardID
|
||||
|
||||
blocks, err := store.GetBlocksForBoard(boardID)
|
||||
blocks, err := store.GetBlocks(model.QueryBlocksOptions{BoardID: boardID})
|
||||
require.NoError(t, err)
|
||||
initialCount := len(blocks)
|
||||
|
||||
@@ -516,7 +516,7 @@ func testDeleteBlock(t *testing.T, store store.Store) {
|
||||
InsertBlocks(t, store, blocksToInsert, "user-id-1")
|
||||
defer DeleteBlocks(t, store, blocksToInsert, "test")
|
||||
|
||||
blocks, err = store.GetBlocksForBoard(boardID)
|
||||
blocks, err = store.GetBlocks(model.QueryBlocksOptions{BoardID: boardID})
|
||||
require.NoError(t, err)
|
||||
require.Len(t, blocks, initialCount+3)
|
||||
|
||||
@@ -550,7 +550,7 @@ func testUndeleteBlock(t *testing.T, store store.Store) {
|
||||
boardID := testBoardID
|
||||
userID := testUserID
|
||||
|
||||
blocks, err := store.GetBlocksForBoard(boardID)
|
||||
blocks, err := store.GetBlocks(model.QueryBlocksOptions{BoardID: boardID})
|
||||
require.NoError(t, err)
|
||||
initialCount := len(blocks)
|
||||
|
||||
@@ -574,7 +574,7 @@ func testUndeleteBlock(t *testing.T, store store.Store) {
|
||||
InsertBlocks(t, store, blocksToInsert, "user-id-1")
|
||||
defer DeleteBlocks(t, store, blocksToInsert, "test")
|
||||
|
||||
blocks, err = store.GetBlocksForBoard(boardID)
|
||||
blocks, err = store.GetBlocks(model.QueryBlocksOptions{BoardID: boardID})
|
||||
require.NoError(t, err)
|
||||
require.Len(t, blocks, initialCount+3)
|
||||
|
||||
@@ -643,7 +643,7 @@ func testUndeleteBlock(t *testing.T, store store.Store) {
|
||||
|
||||
func testGetBlocks(t *testing.T, store store.Store) {
|
||||
boardID := testBoardID
|
||||
blocks, err := store.GetBlocksForBoard(boardID)
|
||||
blocks, err := store.GetBlocks(model.QueryBlocksOptions{BoardID: boardID})
|
||||
require.NoError(t, err)
|
||||
|
||||
blocksToInsert := []*model.Block{
|
||||
@@ -686,65 +686,74 @@ func testGetBlocks(t *testing.T, store store.Store) {
|
||||
InsertBlocks(t, store, blocksToInsert, "user-id-1")
|
||||
defer DeleteBlocks(t, store, blocksToInsert, "test")
|
||||
|
||||
t.Run("not existing parent", func(t *testing.T) {
|
||||
t.Run("not existing parent with type", func(t *testing.T) {
|
||||
time.Sleep(1 * time.Millisecond)
|
||||
blocks, err = store.GetBlocksWithParentAndType(boardID, "not-exists", "test")
|
||||
opts := model.QueryBlocksOptions{BoardID: boardID, ParentID: "not-exists", BlockType: model.BlockType("test")}
|
||||
blocks, err = store.GetBlocks(opts)
|
||||
require.NoError(t, err)
|
||||
require.Empty(t, blocks)
|
||||
})
|
||||
|
||||
t.Run("not existing type", func(t *testing.T) {
|
||||
t.Run("not existing type with parent", func(t *testing.T) {
|
||||
time.Sleep(1 * time.Millisecond)
|
||||
blocks, err = store.GetBlocksWithParentAndType(boardID, "block1", "not-existing")
|
||||
opts := model.QueryBlocksOptions{BoardID: boardID, ParentID: "block1", BlockType: model.BlockType("not-existing")}
|
||||
blocks, err = store.GetBlocks(opts)
|
||||
require.NoError(t, err)
|
||||
require.Empty(t, blocks)
|
||||
})
|
||||
|
||||
t.Run("valid parent and type", func(t *testing.T) {
|
||||
time.Sleep(1 * time.Millisecond)
|
||||
blocks, err = store.GetBlocksWithParentAndType(boardID, "block1", "test")
|
||||
opts := model.QueryBlocksOptions{BoardID: boardID, ParentID: "block1", BlockType: model.BlockType("test")}
|
||||
blocks, err = store.GetBlocks(opts)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, blocks, 2)
|
||||
})
|
||||
|
||||
t.Run("not existing parent", func(t *testing.T) {
|
||||
time.Sleep(1 * time.Millisecond)
|
||||
blocks, err = store.GetBlocksWithParent(boardID, "not-exists")
|
||||
opts := model.QueryBlocksOptions{BoardID: boardID, ParentID: "not-exists"}
|
||||
blocks, err = store.GetBlocks(opts)
|
||||
require.NoError(t, err)
|
||||
require.Empty(t, blocks)
|
||||
})
|
||||
|
||||
t.Run("valid parent", func(t *testing.T) {
|
||||
time.Sleep(1 * time.Millisecond)
|
||||
blocks, err = store.GetBlocksWithParent(boardID, "block1")
|
||||
opts := model.QueryBlocksOptions{BoardID: boardID, ParentID: "block1"}
|
||||
blocks, err = store.GetBlocks(opts)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, blocks, 3)
|
||||
})
|
||||
|
||||
t.Run("not existing type", func(t *testing.T) {
|
||||
time.Sleep(1 * time.Millisecond)
|
||||
blocks, err = store.GetBlocksWithType(boardID, "not-exists")
|
||||
opts := model.QueryBlocksOptions{BoardID: boardID, BlockType: model.BlockType("not-exists")}
|
||||
blocks, err = store.GetBlocks(opts)
|
||||
require.NoError(t, err)
|
||||
require.Empty(t, blocks)
|
||||
})
|
||||
|
||||
t.Run("valid type", func(t *testing.T) {
|
||||
time.Sleep(1 * time.Millisecond)
|
||||
blocks, err = store.GetBlocksWithType(boardID, "test")
|
||||
opts := model.QueryBlocksOptions{BoardID: boardID, BlockType: model.BlockType("test")}
|
||||
blocks, err = store.GetBlocks(opts)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, blocks, 4)
|
||||
})
|
||||
|
||||
t.Run("not existing board", func(t *testing.T) {
|
||||
time.Sleep(1 * time.Millisecond)
|
||||
blocks, err = store.GetBlocksForBoard("not-exists")
|
||||
opts := model.QueryBlocksOptions{BoardID: "not-exists"}
|
||||
blocks, err = store.GetBlocks(opts)
|
||||
require.NoError(t, err)
|
||||
require.Empty(t, blocks)
|
||||
})
|
||||
|
||||
t.Run("all blocks of the a board", func(t *testing.T) {
|
||||
time.Sleep(1 * time.Millisecond)
|
||||
blocks, err = store.GetBlocksForBoard(boardID)
|
||||
opts := model.QueryBlocksOptions{BoardID: boardID}
|
||||
blocks, err = store.GetBlocks(opts)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, blocks, 5)
|
||||
})
|
||||
@@ -863,7 +872,7 @@ func testDuplicateBlock(t *testing.T, store store.Store) {
|
||||
|
||||
func testGetBlockMetadata(t *testing.T, store store.Store) {
|
||||
boardID := testBoardID
|
||||
blocks, err := store.GetBlocksForBoard(boardID)
|
||||
blocks, err := store.GetBlocks(model.QueryBlocksOptions{BoardID: boardID})
|
||||
require.NoError(t, err)
|
||||
|
||||
blocksToInsert := []*model.Block{
|
||||
@@ -1082,12 +1091,20 @@ func testUndeleteBlockChildren(t *testing.T, store store.Store) {
|
||||
require.Nil(t, block)
|
||||
|
||||
// ensure the card children were deleted
|
||||
blocks, err := store.GetBlocksWithParentAndType(cardDelete.BoardID, cardDelete.ID, model.TypeText)
|
||||
blocks, err := store.GetBlocks(model.QueryBlocksOptions{
|
||||
BoardID: cardDelete.BoardID,
|
||||
ParentID: cardDelete.ID,
|
||||
BlockType: model.TypeText},
|
||||
)
|
||||
require.NoError(t, err)
|
||||
assert.Empty(t, blocks)
|
||||
|
||||
// ensure the other card children remain.
|
||||
blocks, err = store.GetBlocksWithParentAndType(cardKeep.BoardID, cardKeep.ID, model.TypeText)
|
||||
blocks, err = store.GetBlocks(model.QueryBlocksOptions{
|
||||
BoardID: cardKeep.BoardID,
|
||||
ParentID: cardKeep.ID,
|
||||
BlockType: model.TypeText},
|
||||
)
|
||||
require.NoError(t, err)
|
||||
assert.Len(t, blocks, len(blocksKeep))
|
||||
|
||||
@@ -1101,7 +1118,11 @@ func testUndeleteBlockChildren(t *testing.T, store store.Store) {
|
||||
require.NotNil(t, block)
|
||||
|
||||
// ensure the card children were restored
|
||||
blocks, err = store.GetBlocksWithParentAndType(cardDelete.BoardID, cardDelete.ID, model.TypeText)
|
||||
blocks, err = store.GetBlocks(model.QueryBlocksOptions{
|
||||
BoardID: cardDelete.BoardID,
|
||||
ParentID: cardDelete.ID,
|
||||
BlockType: model.TypeText},
|
||||
)
|
||||
require.NoError(t, err)
|
||||
assert.Len(t, blocks, len(blocksDelete))
|
||||
})
|
||||
@@ -1117,12 +1138,12 @@ func testUndeleteBlockChildren(t *testing.T, store store.Store) {
|
||||
require.Nil(t, board)
|
||||
|
||||
// ensure all cards and blocks for the board were deleted
|
||||
blocks, err := store.GetBlocksForBoard(boardDelete.ID)
|
||||
blocks, err := store.GetBlocks(model.QueryBlocksOptions{BoardID: boardDelete.ID})
|
||||
require.NoError(t, err)
|
||||
assert.Empty(t, blocks)
|
||||
|
||||
// ensure the other board's cards and blocks remain.
|
||||
blocks, err = store.GetBlocksForBoard(boardKeep.ID)
|
||||
blocks, err = store.GetBlocks(model.QueryBlocksOptions{BoardID: boardKeep.ID})
|
||||
require.NoError(t, err)
|
||||
assert.Len(t, blocks, len(blocksKeep)+len(cardsKeep))
|
||||
|
||||
@@ -1136,7 +1157,7 @@ func testUndeleteBlockChildren(t *testing.T, store store.Store) {
|
||||
require.NotNil(t, board)
|
||||
|
||||
// ensure the board's cards and blocks were restored.
|
||||
blocks, err = store.GetBlocksForBoard(boardDelete.ID)
|
||||
blocks, err = store.GetBlocks(model.QueryBlocksOptions{BoardID: boardDelete.ID})
|
||||
require.NoError(t, err)
|
||||
assert.Len(t, blocks, len(blocksDelete)+len(cardsDelete))
|
||||
})
|
||||
|
||||
@@ -98,7 +98,7 @@ func LoadData(t *testing.T, store store.Store) {
|
||||
func testRunDataRetention(t *testing.T, store store.Store, batchSize int) {
|
||||
LoadData(t, store)
|
||||
|
||||
blocks, err := store.GetBlocksForBoard(boardID)
|
||||
blocks, err := store.GetBlocks(model.QueryBlocksOptions{BoardID: boardID})
|
||||
require.NoError(t, err)
|
||||
require.Len(t, blocks, 4)
|
||||
initialCount := len(blocks)
|
||||
@@ -115,7 +115,7 @@ func testRunDataRetention(t *testing.T, store store.Store, batchSize int) {
|
||||
require.True(t, deletions > int64(initialCount))
|
||||
|
||||
// expect all blocks to be deleted.
|
||||
blocks, errBlocks := store.GetBlocksForBoard(boardID)
|
||||
blocks, errBlocks := store.GetBlocks(model.QueryBlocksOptions{BoardID: boardID})
|
||||
require.NoError(t, errBlocks)
|
||||
require.Equal(t, 0, len(blocks))
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user