@@ -491,6 +491,54 @@ func TestPromoteReleaseBundleWithPromotionTypeFlag(t *testing.T) {
491491 assertStatusCompleted (t , lcManager , tests .LcRbName1 , number1 , "" )
492492}
493493
494+ // TestReleaseBundleFormatFlag verifies the --format flag output of the lifecycle commands:
495+ // - release-bundle-create --format=json emits a JSON confirmation object.
496+ // - release-bundle-promote --format=table renders a summary table.
497+ //
498+ // The release-bundle-promote --format=json (default) path is already covered by promoteRb.
499+ func TestReleaseBundleFormatFlag (t * testing.T ) {
500+ cleanCallback := initLifecycleTest (t , signingKeyOptionalArtifactoryMinVersion )
501+ defer cleanCallback ()
502+ lcManager := getLcServiceManager (t )
503+
504+ deleteBuilds := uploadBuilds (t )
505+ defer deleteBuilds ()
506+
507+ // release-bundle-create --format=json emits a JSON confirmation object.
508+ specFile , err := tests .CreateSpec (tests .LifecycleBuilds12 )
509+ assert .NoError (t , err )
510+ createOutput := lcCli .RunCliCmdWithOutput (t , "rbc" , tests .LcRbName1 , number1 ,
511+ getOption ("spec" , specFile ),
512+ getOption (cliutils .SigningKey , gpgKeyPairName ),
513+ getOption (cliutils .Sync , "true" ),
514+ getOption (cliutils .Format , "json" ))
515+ defer deleteReleaseBundle (t , lcManager , tests .LcRbName1 , number1 )
516+
517+ var created struct {
518+ Name string `json:"release_bundle_name"`
519+ Version string `json:"release_bundle_version"`
520+ Status string `json:"status"`
521+ }
522+ assert .NoError (t , json .Unmarshal ([]byte (createOutput ), & created ))
523+ assert .Equal (t , tests .LcRbName1 , created .Name )
524+ assert .Equal (t , number1 , created .Version )
525+ assert .Equal (t , "created" , created .Status )
526+
527+ // release-bundle-promote --format=table renders a summary table.
528+ tableOutput := lcCli .RunCliCmdWithOutput (t , "rbp" , tests .LcRbName1 , number1 , prodEnvironment ,
529+ getOption (cliutils .SigningKey , gpgKeyPairName ),
530+ getOption (cliutils .IncludeRepos , tests .RtProdRepo1 ),
531+ "--project=default" ,
532+ getOption (cliutils .Format , "table" ))
533+ // The bundle name column wraps across lines, so assert on stable, non-wrapping
534+ // content: the table title, headers, and the environment value.
535+ assert .Contains (t , tableOutput , "Promotion Result" )
536+ assert .Contains (t , tableOutput , "BUNDLE NAME" )
537+ assert .Contains (t , tableOutput , "ENVIRONMENT" )
538+ assert .Contains (t , tableOutput , prodEnvironment )
539+ assertStatusCompleted (t , lcManager , tests .LcRbName1 , number1 , "" )
540+ }
541+
494542func TestReleaseBundleCreationWithDraftFlagFromSpec (t * testing.T ) {
495543 cleanCallback := initLifecycleTest (t , draftBundleArtifactoryMinVersion )
496544 defer cleanCallback ()
0 commit comments