1+ package io.nextflow.gradle
2+
3+ import org.gradle.api.Project
4+ import org.gradle.testfixtures.ProjectBuilder
5+ import spock.lang.Specification
6+
7+ /**
8+ * Unit tests for NextflowPlugin
9+ */
10+ class NextflowPluginTest extends Specification {
11+
12+ Project project
13+
14+ def setup () {
15+ project = ProjectBuilder . builder()
16+ .withName(' test-plugin' )
17+ .build()
18+ project. version = ' 1.0.0'
19+ project. pluginManager. apply(' io.nextflow.nextflow-plugin' )
20+ }
21+
22+ def " should register publishPlugin task when publishing is configured" () {
23+ given :
24+ project. nextflowPlugin {
25+ description = ' A test plugin'
26+ provider = ' Test Author'
27+ className = ' com.example.TestPlugin'
28+ nextflowVersion = ' 24.04.0'
29+ extensionPoints = [' com.example.TestExtension' ]
30+ publishing {
31+ registry {
32+ url = ' https://example.com/registry'
33+ }
34+ }
35+ }
36+
37+ when :
38+ project. evaluate()
39+
40+ then :
41+ project. tasks. findByName(' publishPlugin' ) != null
42+ project. tasks. publishPlugin. group == ' Nextflow Plugin'
43+ project. tasks. publishPlugin. description == ' publish plugin to configured destinations'
44+ }
45+
46+ def " should register publishPlugin task when GitHub publishing is configured" () {
47+ given :
48+ project. nextflowPlugin {
49+ description = ' A test plugin'
50+ provider = ' Test Author'
51+ className = ' com.example.TestPlugin'
52+ nextflowVersion = ' 24.04.0'
53+ extensionPoints = [' com.example.TestExtension' ]
54+ publishing {
55+ github {
56+ repository = ' test-owner/test-repo'
57+ authToken = ' test-token'
58+ }
59+ }
60+ }
61+
62+ when :
63+ project. evaluate()
64+
65+ then :
66+ project. tasks. findByName(' publishPlugin' ) != null
67+ }
68+
69+ def " should make publishPlugin depend on registry publishing task" () {
70+ given :
71+ project. nextflowPlugin {
72+ description = ' A test plugin'
73+ provider = ' Test Author'
74+ className = ' com.example.TestPlugin'
75+ nextflowVersion = ' 24.04.0'
76+ extensionPoints = [' com.example.TestExtension' ]
77+ publishing {
78+ registry {
79+ url = ' https://example.com/registry'
80+ }
81+ }
82+ }
83+
84+ when :
85+ project. evaluate()
86+
87+ then :
88+ def publishPlugin = project. tasks. publishPlugin
89+ def publishToRegistry = project. tasks. publishPluginToRegistry
90+ publishPlugin. taskDependencies. getDependencies(publishPlugin). contains(publishToRegistry)
91+ }
92+
93+ def " should make publishPlugin depend on GitHub publishing tasks" () {
94+ given :
95+ project. nextflowPlugin {
96+ description = ' A test plugin'
97+ provider = ' Test Author'
98+ className = ' com.example.TestPlugin'
99+ nextflowVersion = ' 24.04.0'
100+ extensionPoints = [' com.example.TestExtension' ]
101+ publishing {
102+ github {
103+ repository = ' test-owner/test-repo'
104+ authToken = ' test-token'
105+ updateIndex = true
106+ }
107+ }
108+ }
109+
110+ when :
111+ project. evaluate()
112+
113+ then :
114+ def publishPlugin = project. tasks. publishPlugin
115+ def publishToGithub = project. tasks. publishPluginToGithub
116+ def updateIndex = project. tasks. updateGithubIndex
117+ def dependencies = publishPlugin. taskDependencies. getDependencies(publishPlugin)
118+ dependencies. contains(publishToGithub)
119+ dependencies. contains(updateIndex)
120+ }
121+
122+ def " should not register publishPlugin task when no publishing is configured" () {
123+ given :
124+ project. nextflowPlugin {
125+ description = ' A test plugin'
126+ provider = ' Test Author'
127+ className = ' com.example.TestPlugin'
128+ nextflowVersion = ' 24.04.0'
129+ extensionPoints = [' com.example.TestExtension' ]
130+ }
131+
132+ when :
133+ project. evaluate()
134+
135+ then :
136+ project. tasks. findByName(' publishPlugin' ) == null
137+ }
138+
139+ def " should register publishPlugin with both registry and GitHub publishing" () {
140+ given :
141+ project. nextflowPlugin {
142+ description = ' A test plugin'
143+ provider = ' Test Author'
144+ className = ' com.example.TestPlugin'
145+ nextflowVersion = ' 24.04.0'
146+ extensionPoints = [' com.example.TestExtension' ]
147+ publishing {
148+ registry {
149+ url = ' https://example.com/registry'
150+ }
151+ github {
152+ repository = ' test-owner/test-repo'
153+ authToken = ' test-token'
154+ }
155+ }
156+ }
157+
158+ when :
159+ project. evaluate()
160+
161+ then :
162+ def publishPlugin = project. tasks. publishPlugin
163+ def dependencies = publishPlugin. taskDependencies. getDependencies(publishPlugin)
164+ dependencies. contains(project. tasks. publishPluginToRegistry)
165+ dependencies. contains(project. tasks. publishPluginToGithub)
166+ }
167+ }
0 commit comments