mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-11 16:05:44 +01:00
added unit tests for repository archive
This commit is contained in:
@@ -37,6 +37,7 @@ package sonia.scm.repository;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import sonia.scm.Manager;
|
||||
import sonia.scm.ManagerTestBase;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
@@ -55,6 +56,17 @@ public abstract class RepositoryManagerTestBase
|
||||
extends ManagerTestBase<Repository, RepositoryException>
|
||||
{
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param archiveEnabled
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected abstract RepositoryManager createRepositoryManager(
|
||||
boolean archiveEnabled);
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -96,11 +108,20 @@ public abstract class RepositoryManagerTestBase
|
||||
@Test
|
||||
public void testDelete() throws RepositoryException, IOException
|
||||
{
|
||||
Repository heartOfGold = createTestRepository();
|
||||
String id = heartOfGold.getId();
|
||||
delete(manager, createTestRepository());
|
||||
}
|
||||
|
||||
manager.delete(heartOfGold);
|
||||
assertNull(manager.get(id));
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Test(expected = RepositoryIsNotArchivedException.class)
|
||||
public void testDeleteNonArchived() throws RepositoryException, IOException
|
||||
{
|
||||
delete(createRepositoryManager(true), createTestRepository());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,6 +137,23 @@ public abstract class RepositoryManagerTestBase
|
||||
manager.delete(createRepositoryWithId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Test
|
||||
public void testDeleteWithEnabledArchive()
|
||||
throws RepositoryException, IOException
|
||||
{
|
||||
Repository repository = createTestRepository();
|
||||
|
||||
repository.setArchived(true);
|
||||
delete(createRepositoryManager(true), repository);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -336,4 +374,24 @@ public abstract class RepositoryManagerTestBase
|
||||
{
|
||||
return createRepository(RepositoryTestData.createHeartOfGold());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param manager
|
||||
* @param repository
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
private void delete(Manager<Repository, RepositoryException> manager,
|
||||
Repository repository)
|
||||
throws RepositoryException, IOException
|
||||
{
|
||||
String id = repository.getId();
|
||||
|
||||
manager.delete(repository);
|
||||
assertNull(manager.get(id));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user