-
Notifications
You must be signed in to change notification settings - Fork 1
OmhStorageClient: add resolvePath() function #106
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ import com.dropbox.core.v2.async.LaunchResultBase | |
| import com.dropbox.core.v2.files.CreateFolderResult | ||
| import com.dropbox.core.v2.files.DeleteResult | ||
| import com.dropbox.core.v2.files.FileMetadata | ||
| import com.dropbox.core.v2.files.FolderMetadata | ||
| import com.dropbox.core.v2.files.ListFolderResult | ||
| import com.dropbox.core.v2.files.ListRevisionsMode | ||
| import com.dropbox.core.v2.files.ListRevisionsResult | ||
|
|
@@ -232,4 +233,9 @@ internal class DropboxApiService(internal val apiClient: DropboxApiClient) { | |
| fun getSpaceUsage(): SpaceUsage { | ||
| return apiClient.dropboxApiService.users().spaceUsage | ||
| } | ||
|
|
||
| fun queryNodeIdHaving(path: String): String? { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a suggestion: would it be possible to simplify Since fun queryNodeIdHaving(path: String): String? {
return try {
val metadata = apiClient.dropboxApiService.files().getMetadata(path)
when (metadata) {
is FolderMetadata -> metadata.id
is FileMetadata -> metadata.id
else -> null
}
} catch (e: Exception) {
null
}
}This would still handle files and folders, and gracefully return Let me know what you think!
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch 👍 let's see how this change would work. |
||
| val node: Metadata = apiClient.dropboxApiService.files().getMetadata(path) ?: return null | ||
| return (node as? FolderMetadata)?.id ?: (node as FileMetadata).id | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| package com.openmobilehub.android.storage.plugin.dropbox.testdoubles | ||
|
|
||
| import com.dropbox.core.v2.files.FileMetadata | ||
| import com.dropbox.core.v2.files.FolderMetadata | ||
| import com.dropbox.core.v2.files.ListFolderResult | ||
| import io.mockk.every | ||
| import io.mockk.mockk | ||
|
|
||
| val testQueryRootFolder = mockk<ListFolderResult>(relaxed = true).also { result -> | ||
| every { result.entries } returns listOf(testFolderRsx()) | ||
| } | ||
|
|
||
| val testQueryFolderRsx = mockk<ListFolderResult>(relaxed = true).also { result -> | ||
| every { result.entries } returns listOf(testFolder1()) | ||
| } | ||
|
|
||
| val testQueryFolder1 = mockk<ListFolderResult>(relaxed = true).also { result -> | ||
| every { result.entries } returns listOf(testFolder2()) | ||
| } | ||
|
|
||
| val testQueryFolder2 = mockk<ListFolderResult>(relaxed = true).also { result -> | ||
| every { result.entries } returns listOf(testFolder3()) | ||
| } | ||
|
|
||
| val testQueryFolder3 = mockk<ListFolderResult>(relaxed = true).also { result -> | ||
| every { result.entries } returns listOf(testFileJpg()) | ||
| } | ||
|
|
||
| fun testFolderRsx(): FolderMetadata = mockk<FolderMetadata>().also { folder -> | ||
| every { folder.id } returns "id of folder /RSX" | ||
| every { folder.name } returns "RSX" | ||
| every { folder.parentSharedFolderId } returns "" | ||
| } | ||
|
|
||
| fun testFolder1(): FolderMetadata = mockk<FolderMetadata>().also { folder -> | ||
| every { folder.id } returns "id of folder /RSX/1" | ||
| every { folder.name } returns "1" | ||
| every { folder.parentSharedFolderId } returns "id of folder /RSX" | ||
| } | ||
|
|
||
| fun testFolder2(): FolderMetadata = mockk<FolderMetadata>().also { folder -> | ||
| every { folder.id } returns "id of folder /RSX/1/2" | ||
| every { folder.name } returns "2" | ||
| every { folder.parentSharedFolderId } returns "id of folder /RSX/1" | ||
| } | ||
|
|
||
| fun testFolder3(): FolderMetadata = mockk<FolderMetadata>().also { folder -> | ||
| every { folder.id } returns "id of folder /RSX/1/2/3" | ||
| every { folder.name } returns "3" | ||
| every { folder.parentSharedFolderId } returns "id of folder /RSX/1/2" | ||
| } | ||
|
|
||
| fun testFileJpg(): FileMetadata = FileMetadata( | ||
| "testfile.jpg", | ||
| "id of file /RSX/1/2/3/testfile.jpg", | ||
| TEST_FILE_MODIFIED_TIME, | ||
| TEST_FILE_MODIFIED_TIME, | ||
| "000000000000000000000", | ||
| 12345L | ||
| ) |
Uh oh!
There was an error while loading. Please reload this page.