@@ -18,13 +18,13 @@ import java.nio.file.Paths
1818internal class SourceFileHasherTest : KoinTest {
1919 private val repoAbsolutePath = Paths .get(" " ).toAbsolutePath()
2020 private val outputBasePath = Files .createTempDirectory(" SourceFileHasherTest" )
21+ private val path = Paths .get(" cli/src/test/kotlin/com/bazel_diff/hash/fixture/foo.ts" )
2122 private val fixtureFileTarget = " //cli/src/test/kotlin/com/bazel_diff/hash/fixture:foo.ts"
2223 private val fixtureFileContent: ByteArray
2324 private val seed = " seed" .toByteArray()
2425 private val externalRepoResolver = ExternalRepoResolver (repoAbsolutePath, Paths .get(" bazel" ), outputBasePath)
2526
2627 init {
27- val path = Paths .get(" cli/src/test/kotlin/com/bazel_diff/hash/fixture/foo.ts" )
2828 fixtureFileContent = Files .readAllBytes(path)
2929 }
3030
@@ -47,6 +47,37 @@ internal class SourceFileHasherTest : KoinTest {
4747 assertThat(actual).isEqualTo(expected)
4848 }
4949
50+ @Test
51+ fun testHashConcreteFileWithModifiedFilepathsEnabled () = runBlocking {
52+ val hasher = SourceFileHasher (repoAbsolutePath, null , externalRepoResolver)
53+ val bazelSourceFileTarget = BazelSourceFileTarget (fixtureFileTarget, seed)
54+ val actual = hasher.digest(
55+ bazelSourceFileTarget,
56+ setOf (path)
57+ ).toHexString()
58+ val expected = sha256 {
59+ safePutBytes(fixtureFileContent)
60+ safePutBytes(seed)
61+ safePutBytes(fixtureFileTarget.toByteArray())
62+ }.toHexString()
63+ assertThat(actual).isEqualTo(expected)
64+ }
65+
66+ @Test
67+ fun testHashConcreteFileWithModifiedFilepathsEnabledNoMatch () = runBlocking {
68+ val hasher = SourceFileHasher (repoAbsolutePath, null , externalRepoResolver)
69+ val bazelSourceFileTarget = BazelSourceFileTarget (fixtureFileTarget, seed)
70+ val actual = hasher.digest(
71+ bazelSourceFileTarget,
72+ setOf (Paths .get(" some/other/path" ))
73+ ).toHexString()
74+ val expected = sha256 {
75+ safePutBytes(seed)
76+ safePutBytes(fixtureFileTarget.toByteArray())
77+ }.toHexString()
78+ assertThat(actual).isEqualTo(expected)
79+ }
80+
5081 @Test
5182 fun testHashConcreteFileInExternalRepo () = runBlocking {
5283 val hasher = SourceFileHasher (repoAbsolutePath, null , externalRepoResolver, setOf (" external_repo" ))
0 commit comments