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());
}
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());
}
Aggregations