Skip to content

Commit

Permalink
- fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobi823 committed Nov 24, 2024
1 parent 6958424 commit 29bb14a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ object VersionCompareHelper {
val installed = convertToVersion(installedVersion)
val available = convertToVersion(availableVersion)
// check if the version schema was changed. e.g. Tor Browser switched from 128.x.x to 14.x.x
val versionComparisonNoLongerPossible = (abs(available.major - installed.major) > 0)
val versionComparisonNoLongerPossible = (abs(available.major - installed.major) > 10)
available > installed || versionComparisonNoLongerPossible
} catch (e: IllegalArgumentException) {
installedVersion != availableVersion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import kotlinx.coroutines.runBlocking
import okhttp3.OkHttpClient
import okhttp3.Request
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.Matchers
import org.hamcrest.Matchers.lessThan
import org.junit.jupiter.api.AfterAll
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach
Expand All @@ -42,28 +42,30 @@ class CheckReleaseAgeIT {
TestData(Brave, 28),
TestData(BraveBeta, 14),
TestData(BraveNightly, 7),
TestData(Chromium, 56),
TestData(Cromite, 56),
TestData(DuckDuckGoAndroid, 28),
TestData(FairEmail, 28),
TestData(FennecFdroid, 28),
TestData(FFUpdater, 365),
TestData(Chromium, 60),
TestData(Cromite, 60),
TestData(DuckDuckGoAndroid, 60),
TestData(FairEmail, 60),
TestData(FennecFdroid, 60),
TestData(FFUpdater, 60),
TestData(FirefoxBeta, 21),
TestData(FirefoxFocusBeta, 21),
TestData(FirefoxFocus, 56),
TestData(FirefoxKlar, 56),
TestData(FirefoxFocus, 60),
TestData(FirefoxKlar, 60),
TestData(FirefoxNightly, 7),
TestData(FirefoxRelease, 42),
TestData(K9Mail, 180),
TestData(Iceraven, 84),
TestData(Mulch, 56),
TestData(MulchSystemWebView, 56),
TestData(MullFromRepo, 56),
TestData(Orbot, 4 * 30),
TestData(PrivacyBrowser, 4 * 30),
TestData(Thorium, 56),
TestData(TorBrowserAlpha, 56),
TestData(TorBrowser, 56),
TestData(FirefoxRelease, 60),
TestData(K9Mail, 60),
TestData(Iceraven, 60),
TestData(Mulch, 60),
TestData(MulchSystemWebView, 60),
TestData(MullFromRepo, 60),
TestData(Orbot, 60, "17.3.2-RC-1-tor-0.4.8.12"),
TestData(PrivacyBrowser, 60),
TestData(Thorium, 60, "126.0.6478.246"),
TestData(ThunderbirdRelease, 60),
TestData(ThunderbirdBeta, 60),
TestData(TorBrowserAlpha, 60),
TestData(TorBrowser, 60),
TestData(Vivaldi, null),
)

Expand All @@ -75,7 +77,7 @@ class CheckReleaseAgeIT {
}

@Keep
data class TestData(val appImpl: AppBase, val maxAgeInDays: Int?) {
data class TestData(val appImpl: AppBase, val maxAgeInDays: Int?, val skipAgeCheckForVersion: String? = null) {
override fun toString(): String {
return appImpl.app.toString()
}
Expand Down Expand Up @@ -115,16 +117,9 @@ class CheckReleaseAgeIT {
}

private fun isDownloadAvailable(url: String) {
OkHttpClient.Builder()
.build()
.newCall(
Request.Builder()
.url(url)
.method("HEAD", null)
.build()
)
.execute()
.use { response ->
OkHttpClient.Builder().build().newCall(
Request.Builder().url(url).method("HEAD", null).build()
).execute().use { response ->
Assertions.assertTrue(response.isSuccessful)
}
}
Expand All @@ -138,8 +133,12 @@ class CheckReleaseAgeIT {

if (testData.maxAgeInDays != null) {
val releaseDate = ZonedDateTime.parse(result.publishDate, DateTimeFormatter.ISO_ZONED_DATE_TIME)
val age = Duration.between(releaseDate, ZonedDateTime.now())
assertThat("latest release is too old", age.toDays().toInt(), Matchers.lessThan(testData.maxAgeInDays))
val age = Duration.between(releaseDate, ZonedDateTime.now()).toDays().toInt()
val versionText = result.version.versionText
if (versionText != testData.skipAgeCheckForVersion) {
assertThat("latest release ($versionText) is too old", age, lessThan(testData.maxAgeInDays))
}
assertThat("latest release ($versionText) is way too old", age, lessThan(180))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ class BackgroundSettingsTest : BaseTest() {
"ORBOT",
"PRIVACY_BROWSER",
"THORIUM",
"THUNDERBIRD",
"THUNDERBIRD_BETA,",
"TOR_BROWSER",
"TOR_BROWSER_ALPHA",
"UNGOOGLED_CHROMIUM",
Expand Down

0 comments on commit 29bb14a

Please sign in to comment.