@@ -166,18 +166,20 @@ func TestUploadMTAProjects(t *testing.T) {
166
166
assert .Equal (t , 0 , len (uploader .GetArtifacts ()))
167
167
assert .Equal (t , 0 , len (uploader .uploadedArtifacts ))
168
168
})
169
- t .Run ("Uploading MTA project without artifactId parameter fails " , func (t * testing.T ) {
169
+ t .Run ("Uploading MTA project without artifactId parameter works " , func (t * testing.T ) {
170
170
utils := newMockUtilsBundle (true , false )
171
171
utils .files ["mta.yaml" ] = testMtaYml
172
+ utils .files ["test.mtar" ] = []byte ("contentsOfMtar" )
172
173
utils .cpe [".pipeline/commonPipelineEnvironment/mtarFilePath" ] = "test.mtar"
173
174
uploader := mockUploader {}
174
175
options := createOptions ()
175
176
options .ArtifactID = ""
176
177
177
178
err := runNexusUpload (& utils , & uploader , & options )
178
- assert .EqualError (t , err , "the 'artifactId' parameter was not provided and could not be retrieved from the Common Pipeline Environment" )
179
- assert .Equal (t , 0 , len (uploader .GetArtifacts ()))
180
- assert .Equal (t , 0 , len (uploader .uploadedArtifacts ))
179
+ if assert .NoError (t , err ) {
180
+ assert .Equal (t , 2 , len (uploader .uploadedArtifacts ))
181
+ assert .Equal (t , "test" , uploader .GetArtifactsID ())
182
+ }
181
183
})
182
184
t .Run ("Uploading MTA project fails due to missing yaml file" , func (t * testing.T ) {
183
185
utils := newMockUtilsBundle (true , false )
@@ -274,30 +276,6 @@ func TestUploadMTAProjects(t *testing.T) {
274
276
assert .Equal (t , "0.3.0" , uploader .GetArtifactsVersion ())
275
277
assert .Equal (t , "artifact.id" , uploader .GetArtifactsID ())
276
278
277
- artifacts := uploader .uploadedArtifacts
278
- if assert .Equal (t , 2 , len (artifacts )) {
279
- assert .Equal (t , "mta.yml" , artifacts [0 ].File )
280
- assert .Equal (t , "yaml" , artifacts [0 ].Type )
281
-
282
- assert .Equal (t , "test.mtar" , artifacts [1 ].File )
283
- assert .Equal (t , "mtar" , artifacts [1 ].Type )
284
- }
285
- })
286
- t .Run ("Test uploading mta.yml project works with artifactID from CPE" , func (t * testing.T ) {
287
- utils := newMockUtilsBundle (true , false )
288
- utils .files ["mta.yml" ] = testMtaYml
289
- utils .files ["test.mtar" ] = []byte ("contentsOfMtar" )
290
- utils .cpe [".pipeline/commonPipelineEnvironment/mtarFilePath" ] = "test.mtar"
291
- utils .cpe [".pipeline/commonPipelineEnvironment/configuration/artifactId" ] = "my-artifact-id"
292
- uploader := mockUploader {}
293
- options := createOptions ()
294
- // Clear artifact ID to trigger reading it from the CPE
295
- options .ArtifactID = ""
296
-
297
- err := runNexusUpload (& utils , & uploader , & options )
298
- assert .NoError (t , err , "expected mta.yml project upload to work" )
299
- assert .Equal (t , "my-artifact-id" , uploader .GetArtifactsID ())
300
-
301
279
artifacts := uploader .uploadedArtifacts
302
280
if assert .Equal (t , 2 , len (artifacts )) {
303
281
assert .Equal (t , "mta.yml" , artifacts [0 ].File )
0 commit comments