@@ -15,12 +15,13 @@ import java.nio.file.Files
1515import java.nio.file.Paths
1616
1717
18- internal class SourceFileHasherTest : KoinTest {
18+ internal class SourceFileHasherTest : KoinTest {
1919 private val repoAbsolutePath = Paths .get(" " ).toAbsolutePath()
2020 private val outputBasePath = Files .createTempDirectory(" SourceFileHasherTest" )
2121 private val fixtureFileTarget = " //cli/src/test/kotlin/com/bazel_diff/hash/fixture:foo.ts"
2222 private val fixtureFileContent: ByteArray
2323 private val seed = " seed" .toByteArray()
24+ private val externalRepoResolver = ExternalRepoResolver (repoAbsolutePath, Paths .get(" bazel" ), outputBasePath)
2425
2526 init {
2627 val path = Paths .get(" cli/src/test/kotlin/com/bazel_diff/hash/fixture/foo.ts" )
@@ -35,7 +36,7 @@ internal class SourceFileHasherTest: KoinTest {
3536
3637 @Test
3738 fun testHashConcreteFile () = runBlocking {
38- val hasher = SourceFileHasher (repoAbsolutePath, outputBasePath, null )
39+ val hasher = SourceFileHasher (repoAbsolutePath, null , externalRepoResolver )
3940 val bazelSourceFileTarget = BazelSourceFileTarget (fixtureFileTarget, seed)
4041 val actual = hasher.digest(bazelSourceFileTarget).toHexString()
4142 val expected = sha256 {
@@ -48,7 +49,7 @@ internal class SourceFileHasherTest: KoinTest {
4849
4950 @Test
5051 fun testHashConcreteFileInExternalRepo () = runBlocking {
51- val hasher = SourceFileHasher (repoAbsolutePath, outputBasePath, null , setOf (" external_repo" ))
52+ val hasher = SourceFileHasher (repoAbsolutePath, null , externalRepoResolver , setOf (" external_repo" ))
5253 val externalRepoFilePath = outputBasePath.resolve(" external/external_repo/path/to/my_file.txt" )
5354 Files .createDirectories(externalRepoFilePath.parent)
5455 val externalRepoFileTarget = " @external_repo//path/to:my_file.txt"
@@ -66,7 +67,7 @@ internal class SourceFileHasherTest: KoinTest {
6667
6768 @Test
6869 fun testSoftHashConcreteFile () = runBlocking {
69- val hasher = SourceFileHasher (repoAbsolutePath, outputBasePath, null )
70+ val hasher = SourceFileHasher (repoAbsolutePath, null , externalRepoResolver )
7071 val bazelSourceFileTarget = BazelSourceFileTarget (fixtureFileTarget, seed)
7172 val actual = hasher.softDigest(bazelSourceFileTarget)?.toHexString()
7273 val expected = sha256 {
@@ -79,7 +80,7 @@ internal class SourceFileHasherTest: KoinTest {
7980
8081 @Test
8182 fun testSoftHashNonExistedFile () = runBlocking {
82- val hasher = SourceFileHasher (repoAbsolutePath, outputBasePath, null )
83+ val hasher = SourceFileHasher (repoAbsolutePath, null , externalRepoResolver )
8384 val bazelSourceFileTarget = BazelSourceFileTarget (" //i/do/not/exist" , seed)
8485 val actual = hasher.softDigest(bazelSourceFileTarget)
8586 assertThat(actual).isNull()
@@ -88,7 +89,7 @@ internal class SourceFileHasherTest: KoinTest {
8889 @Test
8990 fun testSoftHashExternalTarget () = runBlocking {
9091 val target = " @bazel-diff//some:file"
91- val hasher = SourceFileHasher (repoAbsolutePath, outputBasePath, null )
92+ val hasher = SourceFileHasher (repoAbsolutePath, null , externalRepoResolver )
9293 val bazelSourceFileTarget = BazelSourceFileTarget (target, seed)
9394 val actual = hasher.softDigest(bazelSourceFileTarget)
9495 assertThat(actual).isNull()
@@ -97,7 +98,7 @@ internal class SourceFileHasherTest: KoinTest {
9798 @Test
9899 fun testHashNonExistedFile () = runBlocking {
99100 val target = " //i/do/not/exist"
100- val hasher = SourceFileHasher (repoAbsolutePath, outputBasePath, null )
101+ val hasher = SourceFileHasher (repoAbsolutePath, null , externalRepoResolver )
101102 val bazelSourceFileTarget = BazelSourceFileTarget (target, seed)
102103 val actual = hasher.digest(bazelSourceFileTarget).toHexString()
103104 val expected = sha256 {
@@ -110,7 +111,7 @@ internal class SourceFileHasherTest: KoinTest {
110111 @Test
111112 fun testHashExternalTarget () = runBlocking {
112113 val target = " @bazel-diff//some:file"
113- val hasher = SourceFileHasher (repoAbsolutePath, outputBasePath, null )
114+ val hasher = SourceFileHasher (repoAbsolutePath, null , externalRepoResolver )
114115 val bazelSourceFileTarget = BazelSourceFileTarget (target, seed)
115116 val actual = hasher.digest(bazelSourceFileTarget).toHexString()
116117 val expected = sha256 {}.toHexString()
@@ -120,7 +121,7 @@ internal class SourceFileHasherTest: KoinTest {
120121 @Test
121122 fun testHashWithProvidedContentHash () = runBlocking {
122123 val filenameToContentHash = hashMapOf(" cli/src/test/kotlin/com/bazel_diff/hash/fixture/foo.ts" to " foo-content-hash" )
123- val hasher = SourceFileHasher (repoAbsolutePath, outputBasePath, filenameToContentHash )
124+ val hasher = SourceFileHasher (repoAbsolutePath, filenameToContentHash, externalRepoResolver )
124125 val bazelSourceFileTarget = BazelSourceFileTarget (fixtureFileTarget, seed)
125126 val actual = hasher.digest(bazelSourceFileTarget).toHexString()
126127 val expected = sha256 {
@@ -134,7 +135,7 @@ internal class SourceFileHasherTest: KoinTest {
134135 @Test
135136 fun testHashWithProvidedContentHashButNotInKey () = runBlocking {
136137 val filenameToContentHash = hashMapOf(" cli/src/test/kotlin/com/bazel_diff/hash/fixture/bar.ts" to " foo-content-hash" )
137- val hasher = SourceFileHasher (repoAbsolutePath, outputBasePath, filenameToContentHash )
138+ val hasher = SourceFileHasher (repoAbsolutePath, filenameToContentHash, externalRepoResolver )
138139 val bazelSourceFileTarget = BazelSourceFileTarget (fixtureFileTarget, seed)
139140 val actual = hasher.digest(bazelSourceFileTarget).toHexString()
140141 val expected = sha256 {
@@ -149,7 +150,7 @@ internal class SourceFileHasherTest: KoinTest {
149150 fun testHashWithProvidedContentHashWithLeadingColon () = runBlocking {
150151 val targetName = " //:cli/src/test/kotlin/com/bazel_diff/hash/fixture/bar.ts"
151152 val filenameToContentHash = hashMapOf(" cli/src/test/kotlin/com/bazel_diff/hash/fixture/bar.ts" to " foo-content-hash" )
152- val hasher = SourceFileHasher (repoAbsolutePath, outputBasePath, filenameToContentHash )
153+ val hasher = SourceFileHasher (repoAbsolutePath, filenameToContentHash, externalRepoResolver )
153154 val bazelSourceFileTarget = BazelSourceFileTarget (targetName, seed)
154155 val actual = hasher.digest(bazelSourceFileTarget).toHexString()
155156 val expected = sha256 {
0 commit comments