Search in sources :

Example 6 with ServerBackup

use of com.thoughtworks.go.server.domain.ServerBackup in project gocd by gocd.

the class ServerBackupRepositoryTest method shouldReturnTheUserNameWhichTriggeredTheLastBackup.

@Test
public void shouldReturnTheUserNameWhichTriggeredTheLastBackup() {
    Date time = new Date();
    repository.save(new ServerBackup("file_path", time, "loser"));
    repository.save(new ServerBackup("file_path", time, "new_loser"));
    assertEquals(new ServerBackup("file_path", time, "new_loser"), repository.lastBackup());
}
Also used : ServerBackup(com.thoughtworks.go.server.domain.ServerBackup) Date(java.util.Date) Test(org.junit.Test)

Example 7 with ServerBackup

use of com.thoughtworks.go.server.domain.ServerBackup in project gocd by gocd.

the class BackupServiceH2IntegrationTest method shouldCreateTheBackupUnderArtifactRepository.

@Test
@RunIf(value = DatabaseChecker.class, arguments = { DatabaseChecker.H2 })
public void shouldCreateTheBackupUnderArtifactRepository() {
    TimeProvider timeProvider = mock(TimeProvider.class);
    DateTime now = new DateTime();
    when(timeProvider.currentDateTime()).thenReturn(now);
    assertThat(backupsDirectory.exists(), is(false));
    HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
    BackupService service = new BackupService(dataSource, artifactsDirHolder, goConfigService, timeProvider, backupInfoRepository, systemEnvironment, serverVersion, configRepository, databaseStrategy);
    service.initialize();
    service.startBackup(admin, result);
    assertThat(result.isSuccessful(), is(true));
    assertThat(backupsDirectory.exists(), is(true));
    assertThat(backupsDirectory.isDirectory(), is(true));
    File backup = new File(backupsDirectory, BackupService.BACKUP + now.toString("YYYYMMdd-HHmmss"));
    assertThat(backup.exists(), is(true));
    assertThat(new File(backup, "db.zip").exists(), is(true));
    assertEquals(new ServerBackup(backup.getAbsolutePath(), now.toDate(), admin.getUsername().toString()), backupInfoRepository.lastBackup());
}
Also used : ServerBackup(com.thoughtworks.go.server.domain.ServerBackup) HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) TimeProvider(com.thoughtworks.go.util.TimeProvider) File(java.io.File) DateTime(org.joda.time.DateTime) RunIf(com.googlecode.junit.ext.RunIf) Test(org.junit.Test)

Aggregations

ServerBackup (com.thoughtworks.go.server.domain.ServerBackup)7 Test (org.junit.Test)5 Date (java.util.Date)4 ServerBackupRepository (com.thoughtworks.go.server.persistence.ServerBackupRepository)2 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)2 File (java.io.File)2 DateTime (org.joda.time.DateTime)2 RunIf (com.googlecode.junit.ext.RunIf)1 TimeProvider (com.thoughtworks.go.util.TimeProvider)1 IOException (java.io.IOException)1 SQLException (java.sql.SQLException)1