Skip to content

Commit

Permalink
Add media inequality test on same file name
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgio committed Aug 28, 2024
1 parent 0e9e4cc commit fb25ff3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions core/src/test/kotlin/eu/iamgio/quarkdown/MediaTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFails
import kotlin.test.assertIs
import kotlin.test.assertNotEquals
import kotlin.test.assertNull
import kotlin.test.assertTrue

Expand Down Expand Up @@ -116,6 +117,15 @@ class MediaTest {
assertTrue(resolved.name.startsWith("banner@"))
assertTrue(resolved.name.endsWith(".png"))
}

localAndRemoteStorage.register("media/path1/logo.png", workingDirectory = File("src/test/resources"))
localAndRemoteStorage.register("media/path2/logo.png", workingDirectory = File("src/test/resources"))

assertEquals(5, localAndRemoteStorage.all.size)
assertNotEquals(
localAndRemoteStorage.resolve("media/path1/logo.png")!!.name,
localAndRemoteStorage.resolve("media/path2/logo.png")!!.name,
)
}

@Test
Expand Down Expand Up @@ -207,7 +217,10 @@ class MediaTest {
height = null,
)

assertEquals("<img src=\"media/https-iamgio.eu-quarkdown-img-logo-light.svg\" alt=\"\" />", remoteImage.accept(renderer))
assertEquals(
"<img src=\"media/https-iamgio.eu-quarkdown-img-logo-light.svg\" alt=\"\" />",
remoteImage.accept(renderer),
)

context.mediaStorage.register("media/icon.png", workingDirectory = File("src/test/resources"))

Expand All @@ -228,7 +241,10 @@ class MediaTest {
localOnlyContext.options.enableLocalMediaStorage = true
localOnlyContext.options.enableRemoteMediaStorage = false

localOnlyContext.mediaStorage.register("https://iamgio.eu/quarkdown/img/logo-light.svg", workingDirectory = null)
localOnlyContext.mediaStorage.register(
"https://iamgio.eu/quarkdown/img/logo-light.svg",
workingDirectory = null,
)

val localOnlyRenderer = QuarkdownHtmlNodeRenderer(localOnlyContext)

Expand Down Expand Up @@ -278,7 +294,9 @@ class MediaTest {

resource.resources.first { it.name == "https-iamgio.eu-quarkdown-img-tbanner-light.png" }.let { banner ->
assertIs<BinaryOutputArtifact>(banner)
assertTrue(URL("https://iamgio.eu/quarkdown/img/tbanner-light.png").readBytes().contentEquals(banner.content))
assertTrue(
URL("https://iamgio.eu/quarkdown/img/tbanner-light.png").readBytes().contentEquals(banner.content),
)
}
}
}
Binary file added core/src/test/resources/media/path1/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added core/src/test/resources/media/path2/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit fb25ff3

Please sign in to comment.