@@ -18,13 +18,13 @@ import java.nio.file.Paths
18
18
internal class SourceFileHasherTest : KoinTest {
19
19
private val repoAbsolutePath = Paths .get(" " ).toAbsolutePath()
20
20
private val outputBasePath = Files .createTempDirectory(" SourceFileHasherTest" )
21
+ private val path = Paths .get(" cli/src/test/kotlin/com/bazel_diff/hash/fixture/foo.ts" )
21
22
private val fixtureFileTarget = " //cli/src/test/kotlin/com/bazel_diff/hash/fixture:foo.ts"
22
23
private val fixtureFileContent: ByteArray
23
24
private val seed = " seed" .toByteArray()
24
25
private val externalRepoResolver = ExternalRepoResolver (repoAbsolutePath, Paths .get(" bazel" ), outputBasePath)
25
26
26
27
init {
27
- val path = Paths .get(" cli/src/test/kotlin/com/bazel_diff/hash/fixture/foo.ts" )
28
28
fixtureFileContent = Files .readAllBytes(path)
29
29
}
30
30
@@ -47,6 +47,37 @@ internal class SourceFileHasherTest : KoinTest {
47
47
assertThat(actual).isEqualTo(expected)
48
48
}
49
49
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
+
50
81
@Test
51
82
fun testHashConcreteFileInExternalRepo () = runBlocking {
52
83
val hasher = SourceFileHasher (repoAbsolutePath, null , externalRepoResolver, setOf (" external_repo" ))
0 commit comments