Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ jobs:
- name: Build Plugin
if: ${{ steps.release.outputs.release_created }}
run: ./gradlew buildPlugin
timeout-minutes: 20

- name: Verify Plugin
if: ${{ steps.release.outputs.release_created }}
run: ./gradlew verifyPlugin
timeout-minutes: 20

- name: Upload Build Artifact
if: ${{ steps.release.outputs.release_created }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ jobs:

- name: Build Plugin
run: ./gradlew buildPlugin
timeout-minutes: 20

- name: Run Tests
run: ./gradlew test
timeout-minutes: 20

- name: Generate Coverage Report
run: ./gradlew koverXmlReport
Expand Down
9 changes: 5 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ dependencies {
}

testImplementation(libs.junit.jupiter)
testRuntimeOnly(libs.junit.platform.launcher)
testImplementation(libs.mockk)
}

Expand Down Expand Up @@ -99,9 +100,9 @@ intellijPlatform {
ides {
// Use specific IDE versions that exist instead of recommended()
// which may select non-existent future versions
ide(IntelliJPlatformType.IntellijIdeaCommunity, "2024.1.7")
ide(IntelliJPlatformType.IntellijIdeaCommunity, "2024.2.4")
ide(IntelliJPlatformType.IntellijIdeaCommunity, "2024.3.1")
create(IntelliJPlatformType.IntellijIdeaCommunity, "2024.1.7")
create(IntelliJPlatformType.IntellijIdeaCommunity, "2024.2.5")
create(IntelliJPlatformType.IntellijIdeaCommunity, "2024.3.5")
}
}
}
Expand Down Expand Up @@ -130,7 +131,7 @@ tasks {
}

wrapper {
gradleVersion = "8.12"
gradleVersion = "9.2.1"
}

publishPlugin {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pluginUntilBuild=253.*

# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin.html#intellij-platform-extension
platformType=IC
platformVersion=2024.1
platformVersion=2024.3.5

# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
platformBundledPlugins=Git4Idea
Expand Down
15 changes: 8 additions & 7 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
[versions]
# Kotlin
kotlin = "2.1.0"
kotlin = "2.3.0"

# Gradle Plugins
changelog = "2.2.1"
intelliJPlatform = "2.2.1"
kover = "0.9.0"
changelog = "2.5.0"
intelliJPlatform = "2.10.5"
kover = "0.9.4"

# Libraries
kotlinxSerialization = "1.7.3"
kotlinxSerialization = "1.9.0"
kotlinxCoroutines = "1.9.0"
toml4j = "0.7.2"
snakeyaml = "2.3"

# Testing
junit = "5.11.3"
mockk = "1.13.13"
junit = "5.11.4"
mockk = "1.14.0"

[plugins]
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
Expand All @@ -30,4 +30,5 @@ kotlinx-coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-cor
toml4j = { group = "com.moandjiezana.toml", name = "toml4j", version.ref = "toml4j" }
snakeyaml = { group = "org.yaml", name = "snakeyaml", version.ref = "snakeyaml" }
junit-jupiter = { group = "org.junit.jupiter", name = "junit-jupiter", version.ref = "junit" }
junit-platform-launcher = { group = "org.junit.platform", name = "junit-platform-launcher", version = "1.11.4" }
mockk = { group = "io.mockk", name = "mockk", version.ref = "mockk" }
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
2 changes: 1 addition & 1 deletion gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

188 changes: 94 additions & 94 deletions gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package xyz.shelltime.jetbrains.version

import com.intellij.ide.BrowserUtil
import com.intellij.notification.Notification
import com.intellij.notification.NotificationAction
import com.intellij.notification.NotificationGroupManager
import com.intellij.notification.NotificationType
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.project.Project
import kotlinx.coroutines.*
import kotlinx.serialization.json.Json
Expand Down Expand Up @@ -90,11 +92,8 @@ class VersionChecker(
"$message<br><br>Run: <code>$updateCommand</code>",
NotificationType.WARNING
)
.addAction(object : com.intellij.notification.NotificationAction("Copy Update Command") {
override fun actionPerformed(
e: com.intellij.notification.AnActionEvent,
notification: com.intellij.notification.Notification
) {
.addAction(object : NotificationAction("Copy Update Command") {
override fun actionPerformed(e: AnActionEvent, notification: Notification) {
val clipboard = java.awt.Toolkit.getDefaultToolkit().systemClipboard
clipboard.setContents(java.awt.datatransfer.StringSelection(updateCommand), null)
notification.expire()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,48 @@ class HeartbeatDataTest {
assertNull(response.platform)
assertNull(response.goVersion)
}

@Test
fun `VersionCheckResponse deserializes correctly with update available`() {
val jsonString = """{"isLatest":false,"latestVersion":"2.0.0","version":"1.0.0"}"""
val response = json.decodeFromString<VersionCheckResponse>(jsonString)

assertFalse(response.isLatest)
assertEquals("2.0.0", response.latestVersion)
assertEquals("1.0.0", response.version)
}

@Test
fun `VersionCheckResponse deserializes correctly when up to date`() {
val jsonString = """{"isLatest":true,"latestVersion":"1.0.0","version":"1.0.0"}"""
val response = json.decodeFromString<VersionCheckResponse>(jsonString)

assertTrue(response.isLatest)
assertEquals("1.0.0", response.latestVersion)
assertEquals("1.0.0", response.version)
}

@Test
fun `VersionCheckResponse serializes correctly`() {
val response = VersionCheckResponse(isLatest = false, latestVersion = "2.0.0", version = "1.0.0")
val jsonString = json.encodeToString(response)

// Deserialize back to verify correct JSON structure
val deserialized = json.decodeFromString<VersionCheckResponse>(jsonString)
assertEquals(response, deserialized)
assertFalse(deserialized.isLatest)
assertEquals("2.0.0", deserialized.latestVersion)
assertEquals("1.0.0", deserialized.version)
}

@Test
fun `VersionCheckResponse ignores unknown fields`() {
val jsonString = """{"isLatest":true,"latestVersion":"1.0.0","version":"1.0.0","unknownField":"value"}"""
val response = json.decodeFromString<VersionCheckResponse>(jsonString)

// Verify unknown field was ignored and known fields were parsed correctly
assertTrue(response.isLatest)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This test is a good check for ignoring unknown fields. To make it more thorough, it would be beneficial to also assert that the known fields (latestVersion and version) were deserialized correctly, ensuring that the presence of an unknown field doesn't interfere with the parsing of known ones.

        assertTrue(response.isLatest)
        assertEquals("1.0.0", response.latestVersion)
        assertEquals("1.0.0", response.version)

assertEquals("1.0.0", response.latestVersion)
assertEquals("1.0.0", response.version)
}
}
Loading