Created
June 2, 2018 04:58
-
-
Save holysheep/7bca6c7a34f4c45a9baaa33f40b6901e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package im.dlg.push | |
import Update | |
import org.junit.After | |
import org.junit.Before | |
import org.junit.Rule | |
import org.junit.Test | |
import org.junit.rules.TemporaryFolder | |
import java.io.File | |
import java.io.FileOutputStream | |
class UpdateNotificationTest { | |
private lateinit var tempFile: File | |
@get:Rule | |
private val temporaryFolder = TemporaryFolder() | |
@Before | |
fun setUp() { | |
val update = Update.VersionUpdate.newBuilder() | |
.apply { | |
version = "1.13.22" | |
storelink = "https://play.google.com/store/apps/details?id=im.dlg.app" | |
} | |
.build() | |
temporaryFolder.create() | |
tempFile = temporaryFolder.newFile("proto.txt") | |
FileOutputStream(tempFile).apply { | |
update.writeTo(this) | |
close() | |
} | |
} | |
@Test | |
fun deserializeUpdateNotificationProto() { | |
Update.VersionUpdate.parseFrom(tempFile.inputStream()) | |
} | |
@Test | |
fun compareAppVersions() { | |
val versionUpdate = Update.VersionUpdate.parseFrom(tempFile.inputStream()) | |
assert(!versionUpdate.version.isNullOrEmpty()) | |
val userAppVersion = "1.13.21" | |
assert(versionUpdate.version > userAppVersion) | |
} | |
@After | |
fun tearDown() { | |
tempFile.delete() | |
assert(!tempFile.exists()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment