mirror of
https://github.com/nextcloud/android.git
synced 2024-11-26 07:05:49 +03:00
add test for successive write in DocumentsStorageProvider
Signed-off-by: Kjell Braden <afflux@pentabarf.de>
This commit is contained in:
parent
d0db9427cd
commit
5127f12a45
1 changed files with 34 additions and 0 deletions
|
@ -218,4 +218,38 @@ class DocumentsStorageProviderIT : AbstractOnServerIT() {
|
|||
val bytes = contentResolver.openInputStream(file1.uri)?.readBytes() ?: ByteArray(0)
|
||||
assertEquals(String(content2), String(bytes))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testServerSuccessive() {
|
||||
// create random file
|
||||
val file1 = rootDir.createFile("text/plain", RandomStringGenerator.make())!!
|
||||
file1.assertRegularFile(size = 0L)
|
||||
|
||||
val createdETag = file1.getOCFile(storageManager)!!.etagOnServer
|
||||
|
||||
assertTrue(createdETag.isNotEmpty())
|
||||
|
||||
val content1 = "initial content".toByteArray()
|
||||
|
||||
// write content bytes to file
|
||||
contentResolver.openOutputStream(file1.uri, "wt").use {
|
||||
it!!.write(content1)
|
||||
}
|
||||
|
||||
// refresh
|
||||
while (file1.getOCFile(storageManager)!!.etagOnServer == createdETag) {
|
||||
shortSleep()
|
||||
rootDir.listFiles()
|
||||
}
|
||||
|
||||
val content2 = "new content".toByteArray()
|
||||
|
||||
contentResolver.openOutputStream(file1.uri, "wt").use {
|
||||
it!!.write(content2)
|
||||
}
|
||||
|
||||
// read back content bytes
|
||||
val bytes = contentResolver.openInputStream(file1.uri)?.readBytes() ?: ByteArray(0)
|
||||
assertEquals(String(content2), String(bytes))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue