File tree 2 files changed +24
-5
lines changed
functionalTest/kotlin/pl/zalas/gradle/structurizrcli
main/kotlin/pl/zalas/gradle/structurizrcli/tasks
2 files changed +24
-5
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ package pl.zalas.gradle.structurizrcli
18
18
import org.junit.jupiter.api.io.TempDir
19
19
import java.io.File
20
20
import kotlin.test.Test
21
+ import kotlin.test.assertEquals
21
22
import kotlin.test.assertTrue
22
23
23
24
class DownloadFunctionalTest : FunctionalTest {
@@ -45,15 +46,33 @@ class DownloadFunctionalTest : FunctionalTest {
45
46
id 'pl.zalas.structurizr-cli'
46
47
}
47
48
structurizrCli {
48
- version = "1.19.0 "
49
+ version = "1.20.1 "
49
50
download {
50
- directory = "downloads "
51
+ directory = "tmp "
51
52
}
52
53
}
53
54
""" )
54
55
55
56
execute(projectDir, " structurizrCliDownload" )
56
57
57
- assertTrue(File (" ${projectDir.absolutePath} /downloads/structurizr-cli-1.19.0.zip" ).exists())
58
+ assertTrue(File (" ${projectDir.absolutePath} /tmp/structurizr-cli-1.20.1.zip" ).exists())
59
+ }
60
+
61
+ @Test
62
+ fun `it downloads the latest version of structurizr cli` (@TempDir projectDir : File ) {
63
+ givenConfiguration(projectDir, """
64
+ plugins {
65
+ id 'pl.zalas.structurizr-cli'
66
+ }
67
+ structurizrCli {
68
+ }
69
+ """ )
70
+
71
+ execute(projectDir, " structurizrCliDownload" )
72
+
73
+ val downloadedFiles = File (" ${projectDir.absolutePath} /build/downloads/" )
74
+ .listFiles { _, fileName -> fileName.matches(" structurizr-cli-.*\\ .zip" .toRegex()) }
75
+
76
+ assertEquals(1 , downloadedFiles.size)
58
77
}
59
78
}
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ open class Version : DefaultTask() {
38
38
39
39
private fun latestVersionProvider (): Provider <String > = project.provider(this ::latestVersion)
40
40
41
- private fun latestVersion (): String = URL (" https://github.com/structurizr/cli/releases/latest" )
41
+ private fun latestVersion (): String = URL (" https://api. github.com/repos /structurizr/cli/releases/latest" )
42
42
.readText()
43
- .replace(" (?smi).*?<h1.*?> v([0-9.]*)< .*" .toRegex(), " $1" )
43
+ .replace(" (?smi).*?\" tag_name \" : \\ s* \" v([0-9.]*)\" .*" .toRegex(), " $1" )
44
44
}
You can’t perform that action at this time.
0 commit comments