use of com.thoughtworks.go.util.SystemTimeClock in project gocd by gocd.
the class ServerVersionInfoManagerTest method shouldBeAbleToUpdateTheLatestGOVersion.
@Test
public void shouldBeAbleToUpdateTheLatestGOVersion() {
SystemTimeClock systemTimeClock = mock(SystemTimeClock.class);
VersionInfo versionInfo = new VersionInfo("go_server", new GoVersion("1.2.3-1"), new GoVersion("2.3.4-1"), null);
Date now = new Date();
when(builder.getServerVersionInfo()).thenReturn(versionInfo);
when(systemTimeClock.currentTime()).thenReturn(now);
manager = new ServerVersionInfoManager(builder, versionInfoDao, systemTimeClock, goCache, systemEnvironment);
manager.initialize();
VersionInfo info = manager.updateLatestVersion("15.0.1-123");
assertThat(info.getLatestVersion().toString(), is("15.0.1-123"));
assertThat(info.getLatestVersionUpdatedAt(), is(now));
verify(versionInfoDao).saveOrUpdate(versionInfo);
}
use of com.thoughtworks.go.util.SystemTimeClock in project gocd by gocd.
the class ServerVersionInfoManagerTest method shouldUpdateCacheWithNewVersionIfLatestVersionIsGreaterThanInstalledVersion.
@Test
public void shouldUpdateCacheWithNewVersionIfLatestVersionIsGreaterThanInstalledVersion() {
SystemTimeClock systemTimeClock = mock(SystemTimeClock.class);
VersionInfo versionInfo = new VersionInfo("go_server", new GoVersion("1.2.3-1"), new GoVersion("1.2.3-1"), null);
Date now = new Date();
when(builder.getServerVersionInfo()).thenReturn(versionInfo);
when(systemTimeClock.currentTime()).thenReturn(now);
manager = new ServerVersionInfoManager(builder, versionInfoDao, systemTimeClock, goCache, systemEnvironment);
manager.initialize();
manager.updateLatestVersion("15.0.1-123");
verify(goCache).put("GOUpdate", "15.0.1-123");
}
use of com.thoughtworks.go.util.SystemTimeClock in project gocd by gocd.
the class ServerVersionInfoManagerTest method shouldBeTrueIfVersionCheckEnabledOnProductionServer.
@Test
public void shouldBeTrueIfVersionCheckEnabledOnProductionServer() {
SystemEnvironment systemEnvironment = mock(SystemEnvironment.class);
when(builder.getServerVersionInfo()).thenReturn(new VersionInfo());
when(systemEnvironment.isGOUpdateCheckEnabled()).thenReturn(true);
when(systemEnvironment.isProductionMode()).thenReturn(true);
manager = new ServerVersionInfoManager(builder, versionInfoDao, new SystemTimeClock(), goCache, systemEnvironment);
manager.initialize();
assertTrue(manager.isUpdateCheckEnabled());
}
Aggregations