Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DefaultUpgradeDialog now supports DisplayState.DownForMaintenance (#9) #23

Merged
merged 4 commits into from
Oct 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ class DefaultUpgradeDialog(
canDismiss = true
)
}
is DisplayState.DownForMaintenance -> {
createBasicDialog(
context,
"Down for Maintenance",
"The server is currently down for maintenance. Please check back later.",
requiresUpdate = false,
canDismiss = false
)
}
// todo 2021-09 Handle down for maintenance
else -> {
dialog?.dismiss()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,4 +238,55 @@ class VersionCheckTest {
}
}

/**
* Server Maintenance
*/
@Test
fun `Status still set to VersionAllowed when the server is down for maintenance`() = runBlocking {
versionCheck = VersionCheck(TestConstants.VersionCheckConfig.serverMaintenanceActive)
versionCheck.statusFlow.test {
assertEquals(Status.Unknown, awaitItem())
versionCheck.runVersionCheck()
assertEquals(Status.VersionAllowed, awaitItem())
confirmLastEmit()
}
}

@Test
fun `DisplayState set to DownForMaintenance when the server is down for maintenance`() = runBlocking {
versionCheck = VersionCheck(TestConstants.VersionCheckConfig.serverMaintenanceActive)
versionCheck.displayStateFlow.test {
assertEquals(awaitItem(),DisplayState.Clear)
versionCheck.runVersionCheck()
assertEquals(awaitItem(),DisplayState.DownForMaintenance)
confirmLastEmit()
}
}

/**
* Server Force Version Update
*/
@Test
fun `Status still set to VersionDisallowed when the serverForceVersionFailure flag is active`() = runBlocking {
versionCheck = VersionCheck(TestConstants.VersionCheckConfig.serverForceVersionFailureActive)
versionCheck.statusFlow.test {
assertEquals(Status.Unknown, awaitItem())
versionCheck.runVersionCheck()
assertEquals(Status.VersionDisallowed, awaitItem())
confirmLastEmit()
}
}

@Test
fun `DisplayState set to ForceUpdate when the serverForceVersionFailure flag is active`() = runBlocking {
versionCheck = VersionCheck(TestConstants.VersionCheckConfig.serverForceVersionFailureActive)
versionCheck.displayStateFlow.test {
assertEquals(awaitItem(),DisplayState.Clear)
versionCheck.runVersionCheck()
assertEquals(awaitItem(),DisplayState.ForceUpdate)
confirmLastEmit()
}
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,40 @@ object TestConstants {
"serverMaintenance": false
}
"""

const val serverMaintenanceActive = """
{
"ios" : {
"minimumVersion": "1.1",
"blockedVersions": ["1.2.0", "1.2.1", "@301"],
"latestTestVersion": "1.4.2@400"
},
"android" : {
"minimumVersion": "1.1",
"blockedVersions": ["1.2.0", "1.2.1", "@301"],
"latestTestVersion": "1.4.2@400"
},
"serverForceVersionFailure": false,
"serverMaintenance": true
}
"""

const val serverForceVersionFailureActive = """
{
"ios" : {
"minimumVersion": "1.1",
"blockedVersions": ["1.2.0", "1.2.1", "@301"],
"latestTestVersion": "1.4.2@400"
},
"android" : {
"minimumVersion": "1.1",
"blockedVersions": ["1.2.0", "1.2.1", "@301"],
"latestTestVersion": "1.4.2@400"
},
"serverForceVersionFailure": true,
"serverMaintenance": false
}
"""
}

object VersionCheckConfig {
Expand Down Expand Up @@ -137,5 +171,23 @@ object TestConstants {
url = "https://this-doesnt-matter",
urlFetcher = MockURLFetcher(MockJson.validVersionDataJson)
)

val serverMaintenanceActive = VersionCheckConfig(
packageDetails = MockPackageDetails.IsNotDevelopmentBuild(
appVersionName = "1.3",
appVersionCode = 400
),
url = "https://this-doesnt-matter",
urlFetcher = MockURLFetcher(MockJson.serverMaintenanceActive)
)

val serverForceVersionFailureActive = VersionCheckConfig(
packageDetails = MockPackageDetails.IsNotDevelopmentBuild(
appVersionName = "1.5",
appVersionCode = 400
),
url = "https://this-doesnt-matter",
urlFetcher = MockURLFetcher(MockJson.serverForceVersionFailureActive)
)
}
}