Skip to content

Commit

Permalink
fix:project startup test
Browse files Browse the repository at this point in the history
  • Loading branch information
cunla committed Apr 27, 2024
1 parent 51e7a02 commit 01b7faa
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/test/kotlin/com/dsoftware/ghmanager/psi/ProjectStartupTest.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package com.dsoftware.ghmanager.psi

import com.intellij.codeInsight.navigation.openFileWithPsiElement
import com.intellij.openapi.components.service
import com.intellij.openapi.extensions.ExtensionPointName
import com.intellij.psi.PsiManager
import com.intellij.testFramework.common.initTestApplication
import com.intellij.testFramework.junit5.RunInEdt
import com.intellij.testFramework.rules.ClassLevelProjectModelExtension
import com.intellij.testFramework.useProject
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.RegisterExtension
Expand All @@ -26,8 +29,6 @@ class ProjectStartupTest {

@Test
fun testScanWorkflowFile() {
val startupActivity =
projectRule.project.extensionArea.getExtensionPoint<ProjectStartup>(ExtensionPointName("com.intellij.postStartupActivity"))
val content = """
jobs:
build:
Expand All @@ -39,12 +40,16 @@ class ProjectStartupTest {
""".trimIndent()
val workflowFile = projectRule.baseProjectDir
.newFile(".github/workflows/workflow1.yaml", content.toByteArray())

.newVirtualFile(".github/workflows/workflow1.yaml", content.toByteArray())

val project = projectRule.project
val gitHubActionDataService = project.service<GitHubActionDataService>()
Assertions.assertEquals(1, gitHubActionDataService.actionsToResolve.size)
project.useProject {
val psiFile = PsiManager.getInstance(project).findFile(workflowFile)
openFileWithPsiElement(psiFile!!, true, true)
val gitHubActionDataService = project.service<GitHubActionDataService>()
Assertions.assertEquals(1, gitHubActionDataService.actionsToResolve.size)
}


// projectResource.after()
}
Expand Down

0 comments on commit 01b7faa

Please sign in to comment.