Skip to content

Commit

Permalink
feat:dotenv for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cunla committed Jan 29, 2024
1 parent cd36096 commit b068055
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ notes.txt
.fleet
.DS_Store
.run
.env
8 changes: 7 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ dependencies {
compileOnly(libs.serialization)
}

testing {
dependencies {
implementation(libs.dotenv)
}
}

kotlin {
jvmToolchain(17)
}
Expand Down Expand Up @@ -80,7 +86,7 @@ tasks {
val start = "<!-- Plugin description -->"
val end = "<!-- Plugin description end -->"

with (it.lines()) {
with(it.lines()) {
if (!containsAll(listOf(start, end))) {
throw GradleException("Plugin description section not found in README.md:\n$start ... $end")
}
Expand Down
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ serialization = "1.6.0"
[libraries]
annotations = { group = "org.jetbrains", name = "annotations", version.ref = "annotations" }
serialization = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "serialization" }
dotenv = { group = "io.github.cdimascio", name = "dotenv-kotlin", version = "6.4.1" }

[plugins]
changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ internal class WfRunsFiltersFactory(vm: WfRunsSearchPanelViewModel) :
onSelect = {},
valuePresenter = { it.name },
popupItemPresenter = {
ChooserPopupUtil.PopupItemPresentation.Simple(it.name.toString())
ChooserPopupUtil.PopupItemPresentation.Simple(it.name)
}),
DropDownComponentFactory(vm.userFilterState)
.create(viewScope,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import com.intellij.testFramework.fixtures.BasePlatformTestCase
import com.intellij.toolWindow.ToolWindowHeadlessManagerImpl.MockToolWindow
import com.intellij.util.ThrowableRunnable
import com.intellij.util.concurrency.annotations.RequiresEdt
import io.github.cdimascio.dotenv.Dotenv
import io.github.cdimascio.dotenv.dotenv
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.yield
import org.jetbrains.plugins.github.api.GithubApiRequestExecutor
Expand Down Expand Up @@ -53,19 +55,21 @@ abstract class GitHubActionsManagerBaseTest : BasePlatformTestCase() {
protected lateinit var host: GithubServerPath
override fun setUp() {
super.setUp()
Dotenv.configure().load()
val dotenv= dotenv()
myProject = project
factory = GhActionsToolWindowFactory()
toolWindow = MockToolWindow(myProject)
host = GithubServerPath.from(System.getenv("idea_test_github_host") ?: System.getenv("idea.test.github.host"))
host = GithubServerPath.from(dotenv.get("idea_test_github_host") ?: dotenv.get("idea.test.github.host"))

val token1 = System.getenv("idea_test_github_token1") ?: System.getenv("idea.test.github.token1")
val token1 = dotenv.get("idea_test_github_token1") ?: dotenv.get("idea.test.github.token1")

assertNotNull(token1)
executor = service<GithubApiRequestExecutor.Factory>().create(token1)
accountManager = service()
repositoriesManager = project.service()

organisation = System.getenv("idea_test_github_org") ?: System.getenv("idea.test.github.org")
organisation = dotenv.get("idea_test_github_org") ?: dotenv.get("idea.test.github.org")
assertNotNull(organisation)
mainAccount = createAccountData(token1)
setCurrentAccount(mainAccount)
Expand Down

0 comments on commit b068055

Please sign in to comment.