11package io.nextflow.gradle
22
3- import io.nextflow.gradle.registry.RegistryPublishConfig
43import org.gradle.api.Project
54import org.gradle.testfixtures.ProjectBuilder
65import spock.lang.Specification
@@ -20,7 +19,7 @@ class NextflowPluginTest extends Specification {
2019 project. pluginManager. apply(' io.nextflow.nextflow-plugin' )
2120 }
2221
23- def " should register publishPlugin task when publishing is configured" () {
22+ def " should register releasePlugin task when publishing is configured" () {
2423 given :
2524 project. nextflowPlugin {
2625 description = ' A test plugin'
@@ -39,13 +38,13 @@ class NextflowPluginTest extends Specification {
3938 project. evaluate()
4039
4140 then :
42- project. tasks. findByName(' publishPlugin ' ) != null
43- project. tasks. publishPlugin . group == ' Nextflow Plugin'
44- project. tasks. publishPlugin . description == ' publish plugin to configured destinations '
41+ project. tasks. findByName(' releasePlugin ' ) != null
42+ project. tasks. releasePlugin . group == ' Nextflow Plugin'
43+ project. tasks. releasePlugin . description == ' Release plugin to configured destination '
4544 }
4645
4746
48- def " should make publishPlugin depend on registry publishing task" () {
47+ def " should make releasePlugin depend on registry publishing task" () {
4948 given :
5049 project. nextflowPlugin {
5150 description = ' A test plugin'
@@ -64,13 +63,13 @@ class NextflowPluginTest extends Specification {
6463 project. evaluate()
6564
6665 then :
67- def publishPlugin = project. tasks. publishPlugin
68- def publishToRegistry = project. tasks. publishPluginToRegistry
69- publishPlugin . taskDependencies. getDependencies(publishPlugin ). contains(publishToRegistry )
66+ def releasePlugin = project. tasks. releasePlugin
67+ def releaseToRegistry = project. tasks. releasePluginToRegistry
68+ releasePlugin . taskDependencies. getDependencies(releasePlugin ). contains(releaseToRegistry )
7069 }
7170
7271
73- def " should not register publishPlugin task when no publishing is configured" () {
72+ def " should not register releasePlugin task when no publishing is configured" () {
7473 given :
7574 project. nextflowPlugin {
7675 description = ' A test plugin'
@@ -84,137 +83,7 @@ class NextflowPluginTest extends Specification {
8483 project. evaluate()
8584
8685 then :
87- project. tasks. findByName(' publishPlugin ' ) == null
86+ project. tasks. findByName(' releasePlugin ' ) == null
8887 }
8988
90- def " should resolve registry URL from explicit configuration" () {
91- given :
92- def config = new RegistryPublishConfig (project)
93- config. url = ' https://custom-registry.com/api'
94-
95- when :
96- def resolvedUrl = config. getResolvedUrl()
97-
98- then :
99- resolvedUrl == ' https://custom-registry.com/api'
100- }
101-
102- def " should resolve registry URL from gradle property" () {
103- given :
104- project. ext. set(' npr.apiUrl' , ' https://gradle-prop-registry.com/api' )
105- def config = new RegistryPublishConfig (project)
106-
107- when :
108- def resolvedUrl = config. getResolvedUrl()
109-
110- then :
111- resolvedUrl == ' https://gradle-prop-registry.com/api'
112- }
113-
114- def " should resolve registry URL from environment variable" () {
115- given :
116- def config = new RegistryPublishConfig (project) {
117- @Override
118- String getResolvedUrl () {
119- // If explicitly set, use it
120- if (url) {
121- return url
122- }
123-
124- // Try gradle property
125- def gradleProp = project. findProperty(' npr.apiUrl' )
126- if (gradleProp) {
127- return gradleProp. toString()
128- }
129-
130- // Mock environment variable for test (NPR_API_URL)
131- return ' https://env-registry.com/api'
132- }
133- }
134-
135- when :
136- def resolvedUrl = config. getResolvedUrl()
137-
138- then :
139- resolvedUrl == ' https://env-registry.com/api'
140- }
141-
142- def " should use default registry URL when none provided" () {
143- given :
144- def config = new RegistryPublishConfig (project)
145-
146- when :
147- def resolvedUrl = config. getResolvedUrl()
148-
149- then :
150- resolvedUrl == ' https://plugin-registry.seqera.io/api'
151- }
152-
153- def " should resolve API key from explicit configuration" () {
154- given :
155- def config = new RegistryPublishConfig (project)
156- config. apiKey = ' explicit-api-key'
157-
158- when :
159- def resolvedApiKey = config. getResolvedApiKey()
160-
161- then :
162- resolvedApiKey == ' explicit-api-key'
163- }
164-
165- def " should resolve API key from gradle property" () {
166- given :
167- project. ext. set(' npr.apiKey' , ' gradle-prop-api-key' )
168- def config = new RegistryPublishConfig (project)
169-
170- when :
171- def resolvedApiKey = config. getResolvedApiKey()
172-
173- then :
174- resolvedApiKey == ' gradle-prop-api-key'
175- }
176-
177- def " should resolve API key from environment variable" () {
178- given :
179- def config = new RegistryPublishConfig (project) {
180- @Override
181- String getResolvedApiKey () {
182- // If explicitly set, use it
183- if (apiKey) {
184- return apiKey
185- }
186-
187- // Try gradle property
188- def gradleProp = project. findProperty(' npr.apiKey' )
189- if (gradleProp) {
190- return gradleProp. toString()
191- }
192-
193- // Mock environment variable for test
194- return ' env-api-key'
195- }
196- }
197-
198- when :
199- def resolvedApiKey = config. getResolvedApiKey()
200-
201- then :
202- resolvedApiKey == ' env-api-key'
203- }
204-
205- def " should throw error when no API key provided" () {
206- given :
207- def config = new RegistryPublishConfig (project)
208-
209- when :
210- config. getResolvedApiKey()
211-
212- then :
213- def ex = thrown(RuntimeException )
214- ex. message. contains(' Registry API key not provided' )
215- ex. message. contains(' nextflowPlugin.publishing.registry.apiKey' )
216- ex. message. contains(' npr.apiKey' )
217- ex. message. contains(' NPR_API_KEY' )
218- }
219-
220- }
89+ }
0 commit comments