5
5
"fmt"
6
6
"github.com/jfrog/gofrog/io"
7
7
"github.com/jfrog/jfrog-cli-core/v2/artifactory/utils"
8
+ "github.com/jfrog/jfrog-cli-core/v2/common/spec"
8
9
configUtils "github.com/jfrog/jfrog-cli-core/v2/utils/config"
9
10
"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
10
11
coreTests "github.com/jfrog/jfrog-cli-core/v2/utils/tests"
@@ -24,6 +25,7 @@ import (
24
25
"os"
25
26
"path"
26
27
"path/filepath"
28
+ "strconv"
27
29
"testing"
28
30
"time"
29
31
)
@@ -167,7 +169,6 @@ func TestLifecycleFullFlow(t *testing.T) {
167
169
// Verify the artifacts were distributed correctly by the provided path mappings.
168
170
assertExpectedArtifacts(t, tests.SearchAllDevRepo, tests.GetExpectedLifecycleDistributedArtifacts())
169
171
*/
170
-
171
172
}
172
173
173
174
// Import bundles only work on onPerm platforms
@@ -215,21 +216,85 @@ func createRbFromSpec(t *testing.T, specName, rbName, rbVersion string, sync boo
215
216
createRb (t , specFile , "spec" , rbName , rbVersion , sync , withoutSigningKey )
216
217
}
217
218
218
- func createRb (t * testing.T , specFilePath , sourceOption , rbName , rbVersion string , sync bool , withoutSigningKey bool ) {
219
- argsAndOptions := []string {
220
- "rbc" ,
221
- rbName ,
222
- rbVersion ,
219
+ func TestCreateBundleWithoutSpec (t * testing.T ) {
220
+ cleanCallback := initLifecycleTest (t , artifactoryLifecycleMinVersion )
221
+ defer cleanCallback ()
222
+
223
+ lcManager := getLcServiceManager (t )
224
+
225
+ deleteBuilds := uploadBuilds (t )
226
+ defer deleteBuilds ()
227
+
228
+ createRbFromBuildNameAndNumber (t , tests .LifecycleBuilds12 , tests .LcRbName1 , number1 , true , false )
229
+ assertStatusCompleted (t , lcManager , tests .LcRbName1 , number1 , "" )
230
+ defer deleteReleaseBundle (t , lcManager , tests .LcRbName1 , number1 )
231
+
232
+ createRbFromBuildNameAndNumber (t , tests .LifecycleBuilds12 , tests .LcRbName1 , number2 , true , true )
233
+ defer deleteReleaseBundle (t , lcManager , tests .LcRbName1 , number2 )
234
+ assertStatusCompleted (t , lcManager , tests .LcRbName1 , number2 , "" )
235
+ }
236
+
237
+ func createRbFromBuildNameAndNumber (t * testing.T , specName , rbName , rbVersion string , sync bool , withoutKey bool ) {
238
+ filePath , err := tests .CreateSpec (specName )
239
+ assert .NoError (t , err )
240
+
241
+ specFile , err := os .Open (filePath )
242
+ if err != nil {
243
+ fmt .Println ("Error opening file:" , err )
244
+ return
245
+ }
246
+ defer specFile .Close ()
247
+ var specData spec.SpecFiles
248
+ decoder := json .NewDecoder (specFile )
249
+ if err := decoder .Decode (& specData ); err != nil {
250
+ fmt .Println ("Error decoding JSON:" , err )
251
+ return
252
+ }
253
+
254
+ buildInfo := specData .Files [0 ].Build
255
+ buildName , buildNumber , err := tests .ExtractBuildInfo (buildInfo )
256
+ assert .NoError (t , err )
257
+
258
+ options := []string {
259
+ getOption (cliutils .BuildName , buildName ),
260
+ getOption (cliutils .BuildNumber , buildNumber ),
261
+ }
262
+
263
+ if ! withoutKey {
264
+ options = append (options , getOption (cliutils .SigningKey , gpgKeyPairName ))
265
+ }
266
+
267
+ if sync {
268
+ options = append (options , getOption (cliutils .Sync , strconv .FormatBool (sync )))
269
+ }
270
+
271
+ createRbWithOptions (t , rbName , rbVersion , options ... )
272
+ }
273
+
274
+ func createRb (t * testing.T , specFilePath , sourceOption , rbName , rbVersion string , sync bool , withoutKey bool ) {
275
+ options := []string {
223
276
getOption (sourceOption , specFilePath ),
224
277
}
225
278
226
- if ! withoutSigningKey {
227
- argsAndOptions = append (argsAndOptions , getOption (cliutils .SigningKey , gpgKeyPairName ))
279
+ if ! withoutKey {
280
+ options = append (options , getOption (cliutils .SigningKey , gpgKeyPairName ))
228
281
}
229
- // Add the --sync option only if requested, to test the default value.
282
+
230
283
if sync {
231
- argsAndOptions = append (argsAndOptions , getOption (cliutils .Sync , "true" ))
284
+ options = append (options , getOption (cliutils .Sync , "true" ))
232
285
}
286
+
287
+ createRbWithOptions (t , rbName , rbVersion , options ... )
288
+ }
289
+
290
+ func createRbWithOptions (t * testing.T , rbName , rbVersion string , options ... string ) {
291
+ argsAndOptions := []string {
292
+ "rbc" ,
293
+ rbName ,
294
+ rbVersion ,
295
+ }
296
+
297
+ argsAndOptions = append (argsAndOptions , options ... )
233
298
assert .NoError (t , lcCli .Exec (argsAndOptions ... ))
234
299
}
235
300
0 commit comments