Fixes image upload testing.
This commit is contained in:
@@ -86,23 +86,23 @@ class ImageUploadTesting {
|
|||||||
val result =
|
val result =
|
||||||
BlossomUploader()
|
BlossomUploader()
|
||||||
.uploadImage(
|
.uploadImage(
|
||||||
inputStream,
|
inputStream = inputStream,
|
||||||
initialHash,
|
hash = initialHash,
|
||||||
paylod.size,
|
length = paylod.size,
|
||||||
"filename.png",
|
baseFileName = "filename.png",
|
||||||
"image/png",
|
contentType = "image/png",
|
||||||
alt = null,
|
alt = null,
|
||||||
sensitiveContent = null,
|
sensitiveContent = null,
|
||||||
server,
|
serverBaseUrl = server.baseUrl,
|
||||||
forceProxy = { false },
|
forceProxy = { false },
|
||||||
createBlossomUploadAuth = account::createBlossomUploadAuth,
|
httpAuth = account::createBlossomUploadAuth,
|
||||||
context = InstrumentationRegistry.getInstrumentation().targetContext,
|
context = InstrumentationRegistry.getInstrumentation().targetContext,
|
||||||
)
|
)
|
||||||
|
|
||||||
assertEquals("image/png", result.type)
|
assertEquals("image/png", result.type)
|
||||||
assertEquals(paylod.size.toLong(), result.size)
|
assertEquals(paylod.size.toLong(), result.size)
|
||||||
assertEquals(initialHash, result.sha256)
|
assertEquals(initialHash, result.sha256)
|
||||||
assertEquals("${server.baseUrl}/$initialHash", result.url)
|
assertEquals("${server.baseUrl}/$initialHash", result.url?.removeSuffix(".png"))
|
||||||
|
|
||||||
val imageData: ByteArray =
|
val imageData: ByteArray =
|
||||||
ImageDownloader().waitAndGetImage(result.url!!, false)
|
ImageDownloader().waitAndGetImage(result.url!!, false)
|
||||||
@@ -128,15 +128,15 @@ class ImageUploadTesting {
|
|||||||
val result =
|
val result =
|
||||||
Nip96Uploader()
|
Nip96Uploader()
|
||||||
.uploadImage(
|
.uploadImage(
|
||||||
inputStream,
|
inputStream = inputStream,
|
||||||
paylod.size.toLong(),
|
length = paylod.size.toLong(),
|
||||||
"image/png",
|
contentType = "image/png",
|
||||||
alt = null,
|
alt = null,
|
||||||
sensitiveContent = null,
|
sensitiveContent = null,
|
||||||
serverInfo,
|
server = serverInfo,
|
||||||
forceProxy = { false },
|
forceProxy = { false },
|
||||||
onProgress = {},
|
onProgress = {},
|
||||||
createHTTPAuthorization = account::createHTTPAuthorization,
|
httpAuth = account::createHTTPAuthorization,
|
||||||
context = InstrumentationRegistry.getInstrumentation().targetContext,
|
context = InstrumentationRegistry.getInstrumentation().targetContext,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -154,19 +154,23 @@ class ImageUploadTesting {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
FileHeader.prepare(
|
val prepared =
|
||||||
imageData,
|
FileHeader.prepare(
|
||||||
"image/png",
|
imageData,
|
||||||
null,
|
"image/png",
|
||||||
onReady = {
|
null,
|
||||||
|
)
|
||||||
|
|
||||||
|
prepared.fold(
|
||||||
|
onSuccess = {
|
||||||
if (dim != null) {
|
if (dim != null) {
|
||||||
assertEquals("${server.name}: Invalid dimensions", it.dim, dim)
|
assertEquals("${server.name}: Invalid dimensions", it.dim.toString(), dim.toString())
|
||||||
}
|
}
|
||||||
if (size != null) {
|
if (size != null) {
|
||||||
assertEquals("${server.name}: Invalid size", it.size.toString(), size)
|
assertEquals("${server.name}: Invalid size", it.size.toString(), size)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onError = { fail("${server.name}: It should not fail") },
|
onFailure = { fail("${server.name}: It should not fail") },
|
||||||
)
|
)
|
||||||
|
|
||||||
// delay(1000)
|
// delay(1000)
|
||||||
@@ -225,6 +229,7 @@ class ImageUploadTesting {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test()
|
@Test()
|
||||||
|
@Ignore("Returns invalid image size")
|
||||||
fun testNostrPic() =
|
fun testNostrPic() =
|
||||||
runBlocking {
|
runBlocking {
|
||||||
testBase(ServerName("nostpic.com", "https://nostpic.com", ServerType.NIP96))
|
testBase(ServerName("nostpic.com", "https://nostpic.com", ServerType.NIP96))
|
||||||
|
|||||||
+2
-3
@@ -35,11 +35,10 @@ enum class ServerType {
|
|||||||
val DEFAULT_MEDIA_SERVERS: List<ServerName> =
|
val DEFAULT_MEDIA_SERVERS: List<ServerName> =
|
||||||
listOf(
|
listOf(
|
||||||
ServerName("Nostr.Build", "https://nostr.build", ServerType.NIP96),
|
ServerName("Nostr.Build", "https://nostr.build", ServerType.NIP96),
|
||||||
ServerName("NostrCheck.me", "https://nostrcheck.me", ServerType.NIP96),
|
ServerName("NostrCheck.me (NIP-96)", "https://nostrcheck.me", ServerType.NIP96),
|
||||||
ServerName("NostPic", "https://nostpic.com", ServerType.NIP96),
|
|
||||||
ServerName("Sovbit", "https://files.sovbit.host", ServerType.NIP96),
|
ServerName("Sovbit", "https://files.sovbit.host", ServerType.NIP96),
|
||||||
ServerName("Void.cat", "https://void.cat", ServerType.NIP96),
|
ServerName("Void.cat", "https://void.cat", ServerType.NIP96),
|
||||||
ServerName("Satellite (Paid)", "https://cdn.satellite.earth", ServerType.Blossom),
|
ServerName("Satellite (Paid)", "https://cdn.satellite.earth", ServerType.Blossom),
|
||||||
ServerName("NostrCheck.me (Blossom)", "https://cdn.nostrcheck.me", ServerType.Blossom),
|
ServerName("NostrCheck.me (Blossom)", "https://cdn.nostrcheck.me", ServerType.Blossom),
|
||||||
ServerName("Primal", "https://blossom.primal.net", ServerType.Blossom),
|
ServerName("Nostr.Download", "https://nostr.download", ServerType.Blossom),
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user