func (s *workItemLinkSuite) cleanup() {
	// First delete work item links and then the types;
	// otherwise referential integrity will be violated.
	for _, id := range s.deleteWorkItemLinks {
		db := s.DB.Unscoped().Delete(&link.WorkItemLink{ID: id})
		require.Nil(s.T(), db.Error)
	}
	s.deleteWorkItemLinks = nil

	// Delete all work item links for now
	db := s.DB.Unscoped().Delete(&link.WorkItemLink{})
	require.Nil(s.T(), db.Error)

	// Delete work item link types and categories by name.
	// They will be created during the tests but have to be deleted by name
	// rather than ID, unlike the work items or work item links.
	db = db.Unscoped().Delete(&link.WorkItemLinkType{Name: "test-bug-blocker"})
	require.Nil(s.T(), db.Error)
	db = db.Unscoped().Delete(&link.WorkItemLinkCategory{Name: "test-user"})
	require.Nil(s.T(), db.Error)
	if s.userSpaceID != uuid.Nil {
		db = db.Unscoped().Delete(&space.Space{ID: s.userSpaceID})
		require.Nil(s.T(), db.Error)
	}

	// Last but not least delete the work items
	for _, idStr := range s.deleteWorkItems {
		id, err := strconv.ParseUint(idStr, 10, 64)
		require.Nil(s.T(), err)
		db = db.Unscoped().Delete(&workitem.WorkItemStorage{ID: id})
		require.Nil(s.T(), db.Error)
	}
	s.deleteWorkItems = nil
}
// cleanup removes all DB entries that will be created or have been created
// with this test suite. We need to remove them completely and not only set the
// "deleted_at" field, which is why we need the Unscoped() function.
cleanup removes all DB entries that will be created or have been created
with this test suite. We need to remove them completely and not only set the
"deleted_at" field, which is why we need the Unscoped() function.
// cleanup removes all DB entries that will be created or have been created // with this test suite . We need to remove them completely and not only set the // " deleted_at " field which is why we need the Unscoped () function .
func (s *workItemLinkSuite) cleanup() {
	for _, id := range s.deleteWorkItemLinks {
		db := s.DB.Unscoped().Delete(&link.WorkItemLink{ID: id})
		require.Nil(s.T(), db.Error)
	}
	s.deleteWorkItemLinks = nil
	db := s.DB.Unscoped().Delete(&link.WorkItemLink{})
	require.Nil(s.T(), db.Error)
	db = db.Unscoped().Delete(&link.WorkItemLinkType{Name: "test-bug-blocker"})
	require.Nil(s.T(), db.Error)
	db = db.Unscoped().Delete(&link.WorkItemLinkCategory{Name: "test-user"})
	require.Nil(s.T(), db.Error)
	if s.userSpaceID != uuid.Nil {
		db = db.Unscoped().Delete(&space.Space{ID: s.userSpaceID})
		require.Nil(s.T(), db.Error)
	}
	for _, idStr := range s.deleteWorkItems {
		id, err := strconv.ParseUint(idStr, 10, 64)
		require.Nil(s.T(), err)
		db = db.Unscoped().Delete(&workitem.WorkItemStorage{ID: id})
		require.Nil(s.T(), db.Error)
	}
	s.deleteWorkItems = nil
}
func ( s * workItemLinkSuite ) cleanup ( ) { for _ , id := range s . deleteWorkItemLinks { db := s . DB . Unscoped ( ) . Delete ( & link . WorkItemLink { ID : id } ) require . Nil ( s . T ( ) , db . Error ) } s . deleteWorkItemLinks = nil db := s . DB . Unscoped ( ) . Delete ( & link . WorkItemLink { } ) require . Nil ( s . T ( ) , db . Error ) db = db . Unscoped ( ) . Delete ( & link . WorkItemLinkType { Name : " " } ) require . Nil ( s . T ( ) , db . Error ) db = db . Unscoped ( ) . Delete ( & link . WorkItemLinkCategory { Name : " " } ) require . Nil ( s . T ( ) , db . Error ) if s . userSpaceID != uuid . Nil { db = db . Unscoped ( ) . Delete ( & space . Space { ID : s . userSpaceID } ) require . Nil ( s . T ( ) , db . Error ) } for _ , idStr := range s . deleteWorkItems { id , err := strconv . ParseUint ( idStr , 10 , 64 ) require . Nil ( s . T ( ) , err ) db = db . Unscoped ( ) . Delete ( & workitem . WorkItemStorage { ID : id } ) require . Nil ( s . T ( ) , db . Error ) } s . deleteWorkItems = nil }
cleanup removes all DB entries that will be created or have been created
with this test suite.
cleanup removes all DB entries that will be created or have been created with this test suite .
// First delete work item links and then the types; // otherwise referential integrity will be violated. // Delete all work item links for now // Delete work item link types and categories by name. // They will be created during the tests but have to be deleted by name // rather than ID, unlike the work items or work item links. // Last but not least delete the work items