Fix broken unit test with manual dependency injection
This commit is contained in:
parent
52539c2692
commit
6748f5288c
1 changed files with 14 additions and 5 deletions
|
@ -1,13 +1,13 @@
|
||||||
package com.jetpackduba.gitnuro.app.git
|
package com.jetpackduba.gitnuro.app.git
|
||||||
|
|
||||||
import com.jetpackduba.gitnuro.credentials.GProcess
|
import com.jetpackduba.gitnuro.credentials.*
|
||||||
import com.jetpackduba.gitnuro.credentials.GRemoteSession
|
import com.jetpackduba.gitnuro.di.factories.HttpCredentialsFactory
|
||||||
import com.jetpackduba.gitnuro.credentials.GSessionManager
|
|
||||||
import com.jetpackduba.gitnuro.git.remote_operations.CloneRepositoryUseCase
|
import com.jetpackduba.gitnuro.git.remote_operations.CloneRepositoryUseCase
|
||||||
import com.jetpackduba.gitnuro.git.remote_operations.HandleTransportUseCase
|
import com.jetpackduba.gitnuro.git.remote_operations.HandleTransportUseCase
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.flow.flowOn
|
import kotlinx.coroutines.flow.flowOn
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
|
import org.eclipse.jgit.api.Git
|
||||||
import org.junit.jupiter.api.extension.AfterAllCallback
|
import org.junit.jupiter.api.extension.AfterAllCallback
|
||||||
import org.junit.jupiter.api.extension.BeforeAllCallback
|
import org.junit.jupiter.api.extension.BeforeAllCallback
|
||||||
import org.junit.jupiter.api.extension.ExtensionContext
|
import org.junit.jupiter.api.extension.ExtensionContext
|
||||||
|
@ -32,12 +32,21 @@ class BeforeRepoAllTestsExtension : BeforeAllCallback, AfterAllCallback {
|
||||||
// The following line registers a callback hook when the root test context is shut down
|
// The following line registers a callback hook when the root test context is shut down
|
||||||
context.root.getStore(GLOBAL).put("gitnuro_tests", this)
|
context.root.getStore(GLOBAL).put("gitnuro_tests", this)
|
||||||
|
|
||||||
|
val credentialsStateManager = CredentialsStateManager()
|
||||||
val cloneRepositoryUseCase =
|
val cloneRepositoryUseCase =
|
||||||
CloneRepositoryUseCase(HandleTransportUseCase(GSessionManager { GRemoteSession { GProcess() } }))
|
CloneRepositoryUseCase(
|
||||||
|
HandleTransportUseCase(
|
||||||
|
sessionManager = GSessionManager { GRemoteSession({ GProcess() }, credentialsStateManager) },
|
||||||
|
httpCredentialsProvider = object : HttpCredentialsFactory {
|
||||||
|
override fun create(git: Git?): HttpCredentialsProvider =
|
||||||
|
HttpCredentialsProvider(credentialsStateManager, git)
|
||||||
|
},
|
||||||
|
)
|
||||||
|
)
|
||||||
cloneRepositoryUseCase(repoDir, REPO_URL)
|
cloneRepositoryUseCase(repoDir, REPO_URL)
|
||||||
.flowOn(Dispatchers.IO)
|
.flowOn(Dispatchers.IO)
|
||||||
.collect { newCloneStatus ->
|
.collect { newCloneStatus ->
|
||||||
println("Clonning test repository: $newCloneStatus")
|
println("Cloning test repository: $newCloneStatus")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue