diff --git a/src/main/kotlin/com/dsoftware/ghmanager/data/WorkflowDataContextService.kt b/src/main/kotlin/com/dsoftware/ghmanager/data/WorkflowDataContextService.kt index 05a10213..22ffa548 100644 --- a/src/main/kotlin/com/dsoftware/ghmanager/data/WorkflowDataContextService.kt +++ b/src/main/kotlin/com/dsoftware/ghmanager/data/WorkflowDataContextService.kt @@ -92,7 +92,7 @@ class WorkflowDataContextService(project: Project) { settingsService.state.apiToken } - val requestExecutor = GithubApiRequestExecutor.Factory.Companion.getInstance().create(token) + val requestExecutor = GithubApiRequestExecutor.Factory.Companion.getInstance().create(token=token) val singleRunDataLoader = SingleRunDataLoader(requestExecutor) requestExecutor.addListener(singleRunDataLoader) { singleRunDataLoader.invalidateAllData() diff --git a/src/test/kotlin/com/dsoftware/ghmanager/TestWindowTabController.kt b/src/test/kotlin/com/dsoftware/ghmanager/TestWindowTabController.kt index a5be5b03..3fa942f1 100644 --- a/src/test/kotlin/com/dsoftware/ghmanager/TestWindowTabController.kt +++ b/src/test/kotlin/com/dsoftware/ghmanager/TestWindowTabController.kt @@ -11,6 +11,7 @@ import io.mockk.every import io.mockk.mockk import io.mockk.mockkObject import io.mockk.mockkStatic +import io.mockk.verify import junit.framework.TestCase import org.jetbrains.plugins.github.api.GithubApiRequest import org.jetbrains.plugins.github.api.GithubApiRequestExecutor @@ -28,6 +29,11 @@ class TestWindowTabController : GitHubActionsManagerBaseTest() { mockGhActionsService(setOf("http://github.com/owner/repo"), setOf("account1")) mockkStatic(GHCompatibilityUtil::class) every { GHCompatibilityUtil.getOrRequestToken(any(), any()) } returns "token" + executorMock = mockk(relaxed = true) {} + mockkObject(GithubApiRequestExecutor.Factory) + every { GithubApiRequestExecutor.Factory.getInstance() } returns mockk { + every { create(token = any()) } returns executorMock + } workflowDataContextService = project.service() factory.init(toolWindow) executeSomeCoroutineTasksAndDispatchAllInvocationEvents(project) @@ -48,6 +54,9 @@ class TestWindowTabController : GitHubActionsManagerBaseTest() { val workflowRunSelectionContext: WorkflowRunSelectionContext = workflowDataContextService.repositories.values.first().value.get() TestCase.assertEquals(0, workflowRunSelectionContext.runsListModel.size) + verify { + executorMock.execute(any(), ofType(GithubApiRequest::class)) + } } private fun mockGithubApiRequestExecutor( @@ -69,7 +78,7 @@ class TestWindowTabController : GitHubActionsManagerBaseTest() { branch }) val workflowTypesResponse = WorkflowTypes(workflowTypes.size, workflowTypes.toList()) - executorMock = mockk(relaxed = true) { + executorMock.apply { every { execute(any(), any>()) } returns WorkflowRuns(workflowRunsList.size, workflowRunsList.toList()) @@ -83,9 +92,6 @@ class TestWindowTabController : GitHubActionsManagerBaseTest() { execute(any(), any>()) } returns workflowTypesResponse } - mockkObject(GithubApiRequestExecutor.Factory) - every { GithubApiRequestExecutor.Factory.getInstance() } returns mockk { - every { create(token = any()) } returns executorMock - } + } } \ No newline at end of file