Search in sources :

Example 16 with VersionInfo

use of com.thoughtworks.go.domain.VersionInfo in project gocd by gocd.

the class ServerVersionInfoBuilderTest method shouldGetVersionInfoForGOServerIfExists.

@Test
public void shouldGetVersionInfoForGOServerIfExists() {
    VersionInfo goVersionInfo = new VersionInfo("go_server", new GoVersion("1.2.3-1"));
    when(versionInfoDao.findByComponentName("go_server")).thenReturn(goVersionInfo);
    when(serverVersion.version()).thenReturn("1.2.3-1");
    VersionInfo versionInfo = builder.getServerVersionInfo();
    assertThat(versionInfo.getComponentName(), is(goVersionInfo.getComponentName()));
    assertThat(versionInfo.getInstalledVersion(), is(goVersionInfo.getInstalledVersion()));
}
Also used : VersionInfo(com.thoughtworks.go.domain.VersionInfo) GoVersion(com.thoughtworks.go.domain.GoVersion) Test(org.junit.Test)

Example 17 with VersionInfo

use of com.thoughtworks.go.domain.VersionInfo in project gocd by gocd.

the class ServerVersionInfoBuilderTest method shouldNotCreateAVersionInfoOnDevelopmentServer.

@Test
public void shouldNotCreateAVersionInfoOnDevelopmentServer() {
    when(versionInfoDao.findByComponentName("go_server")).thenReturn(null);
    when(serverVersion.version()).thenReturn("N/A");
    VersionInfo versionInfo = builder.getServerVersionInfo();
    verify(versionInfoDao, never()).saveOrUpdate(isA(VersionInfo.class));
    assertNull(versionInfo);
}
Also used : VersionInfo(com.thoughtworks.go.domain.VersionInfo) Test(org.junit.Test)

Example 18 with VersionInfo

use of com.thoughtworks.go.domain.VersionInfo 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);
}
Also used : VersionInfo(com.thoughtworks.go.domain.VersionInfo) SystemTimeClock(com.thoughtworks.go.util.SystemTimeClock) GoVersion(com.thoughtworks.go.domain.GoVersion) Date(java.util.Date) Test(org.junit.Test)

Example 19 with VersionInfo

use of com.thoughtworks.go.domain.VersionInfo in project gocd by gocd.

the class ServerVersionInfoManagerTest method shouldNotReturnVersionInfoIfLatestVersionUpdatedToday.

@Test
public void shouldNotReturnVersionInfoIfLatestVersionUpdatedToday() {
    Date today = new Date();
    VersionInfo versionInfo = new VersionInfo("go_server", new GoVersion("1.2.3-1"), new GoVersion("2.3.4-2"), today);
    when(builder.getServerVersionInfo()).thenReturn(versionInfo);
    manager.initialize();
    VersionInfo serverVersionInfo = manager.versionInfoForUpdate();
    assertNull(serverVersionInfo);
}
Also used : VersionInfo(com.thoughtworks.go.domain.VersionInfo) GoVersion(com.thoughtworks.go.domain.GoVersion) Date(java.util.Date) Test(org.junit.Test)

Example 20 with VersionInfo

use of com.thoughtworks.go.domain.VersionInfo in project gocd by gocd.

the class ServerVersionInfoManagerTest method shouldNotUpdateCacheIfLatestVersionIsLesserThanInstalledVersion.

@Test
public void shouldNotUpdateCacheIfLatestVersionIsLesserThanInstalledVersion() {
    GoVersion currentVersion = new GoVersion("4.7.3-1");
    GoVersion latestVersion = new GoVersion("2.3.4-2");
    VersionInfo versionInfo = new VersionInfo("go_server", currentVersion, latestVersion, null);
    when(builder.getServerVersionInfo()).thenReturn(versionInfo);
    manager.initialize();
    verify(builder).getServerVersionInfo();
    verify(goCache, never()).put(anyString(), anyString());
}
Also used : VersionInfo(com.thoughtworks.go.domain.VersionInfo) GoVersion(com.thoughtworks.go.domain.GoVersion) Test(org.junit.Test)

Aggregations

VersionInfo (com.thoughtworks.go.domain.VersionInfo)22 Test (org.junit.Test)21 GoVersion (com.thoughtworks.go.domain.GoVersion)14 Date (java.util.Date)8 SystemTimeClock (com.thoughtworks.go.util.SystemTimeClock)6 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)3 DateTime (org.joda.time.DateTime)1