Skip to content

Commit

Permalink
feat:test with http404 for wf-runs
Browse files Browse the repository at this point in the history
  • Loading branch information
cunla committed Apr 12, 2024
1 parent 90ac9b1 commit b310534
Showing 1 changed file with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import io.mockk.mockkObject
import io.mockk.mockkStatic
import io.mockk.verify
import org.jetbrains.plugins.github.api.GithubApiRequest
import org.jetbrains.plugins.github.api.GithubApiRequestExecutor
import org.jetbrains.plugins.github.api.data.GithubBranch
import org.jetbrains.plugins.github.api.data.GithubResponsePage
import org.jetbrains.plugins.github.api.data.GithubUserWithPermissions
import org.jetbrains.plugins.github.exceptions.GithubStatusCodeException
import org.jetbrains.plugins.github.util.GHCompatibilityUtil
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach
Expand Down Expand Up @@ -99,6 +99,34 @@ class TestRepoTabControllerWorkflowRunsPanel : GitHubActionsManagerBaseTest() {
Assertions.assertEquals(0, workflowRunsListPanel.runListComponent.model.size)
}

@Test
fun `test not able to get repo wf-runs - http404`() {
executorMock.apply {
every {// workflow runs
execute(any(), matchApiRequestUrl<WorkflowRuns>("/actions/runs")).hint(WorkflowRuns::class)
} throws GithubStatusCodeException("Not Found", 404)
}
mockkObject(GhApiRequestExecutor)
every { GhApiRequestExecutor.create(token = any()) } returns executorMock
executeSomeCoroutineTasksAndDispatchAllInvocationEvents(projectRule.project)

// act
toolWindowContent.createContent()
executeSomeCoroutineTasksAndDispatchAllInvocationEvents(projectRule.project)

// assert
val (workflowRunsListPanel, jobsListPanel, logPanel) = assertTabsAndPanels()

workflowRunsListPanel.runListComponent.emptyText.apply {
Assertions.assertEquals(message("panel.workflow-runs.error"), text)
Assertions.assertEquals(2, wrappedFragmentsIterable.count())
val fragments = wrappedFragmentsIterable.toList()
Assertions.assertEquals(message("panel.workflow-runs.error"), fragments[0].toString())
Assertions.assertEquals("Not Found.", fragments[1].toString())
}
Assertions.assertEquals(0, workflowRunsListPanel.runListComponent.model.size)
}


fun mockGithubApiRequestExecutor(
workflowRunsList: Collection<WorkflowRun>,
Expand Down

0 comments on commit b310534

Please sign in to comment.