@@ -431,135 +431,18 @@ func Test_Apps_Link(t *testing.T) {
431431 CmdArgs : []string {},
432432 ExpectedError : slackerror .New (slackerror .ErrAppNotFound ),
433433 },
434- "accepting manifest source prompt should save information about the provided deployed app " : {
434+ "links app when manifest source is local " : {
435435 Setup : func (t * testing.T , ctx context.Context , cm * shared.ClientsMock , cf * shared.ClientFactory ) {
436436 cm .Auth .On ("Auths" , mock .Anything ).Return ([]types.SlackAuth {
437437 mockLinkSlackAuth2 ,
438438 mockLinkSlackAuth1 ,
439439 }, nil )
440440 cm .AddDefaultMocks ()
441441 setupAppLinkCommandMocks (t , ctx , cm , cf )
442- // Set manifest source to project to trigger confirmation prompt
443- if err := config .SetManifestSource (ctx , cm .Fs , cm .Os , config .ManifestSourceLocal ); err != nil {
444- require .FailNow (t , fmt .Sprintf ("Failed to set the manifest source in the memory-based file system: %s" , err ))
445- }
446- // Accept manifest source confirmation prompt
447- cm .IO .On ("ConfirmPrompt" ,
448- mock .Anything ,
449- LinkAppManifestSourceConfirmPromptText ,
450- mock .Anything ,
451- ).Return (true , nil )
452- cm .IO .On ("SelectPrompt" ,
453- mock .Anything ,
454- "Select the existing app team" ,
455- mock .Anything ,
456- mock .Anything ,
457- mock .Anything ,
458- ).Return (iostreams.SelectPromptResponse {
459- Flag : true ,
460- Option : mockLinkSlackAuth1 .TeamDomain ,
461- }, nil )
462- cm .IO .On ("InputPrompt" ,
463- mock .Anything ,
464- "Enter the existing app ID" ,
465- mock .Anything ,
466- ).Return (mockLinkAppID1 , nil )
467- cm .IO .On ("SelectPrompt" ,
468- mock .Anything ,
469- "Choose the app environment" ,
470- mock .Anything ,
471- mock .Anything ,
472- mock .Anything ,
473- ).Return (iostreams.SelectPromptResponse {
474- Flag : true ,
475- Option : "deployed" ,
476- }, nil )
477- cm .API .On (
478- "GetAppStatus" ,
479- mock .Anything ,
480- mockLinkSlackAuth1 .Token ,
481- []string {mockLinkAppID1 },
482- mockLinkSlackAuth1 .TeamID ,
483- ).Return (api.GetAppStatusResult {}, nil )
484- },
485- CmdArgs : []string {},
486- ExpectedAsserts : func (t * testing.T , ctx context.Context , cm * shared.ClientsMock ) {
487- expectedApp := types.App {
488- AppID : mockLinkAppID1 ,
489- TeamDomain : mockLinkSlackAuth1 .TeamDomain ,
490- TeamID : mockLinkSlackAuth1 .TeamID ,
491- EnterpriseID : mockLinkSlackAuth1 .EnterpriseID ,
492- }
493- actualApp , err := cm .AppClient .GetDeployed (
494- ctx ,
495- mockLinkSlackAuth1 .TeamID ,
496- )
497- require .NoError (t , err )
498- assert .Equal (t , expectedApp , actualApp )
499- // Assert manifest confirmation prompt accepted
500- cm .IO .AssertCalled (t , "ConfirmPrompt" ,
501- mock .Anything ,
502- LinkAppManifestSourceConfirmPromptText ,
503- mock .Anything ,
504- )
505- },
506- },
507- "declining manifest source prompt should not link app" : {
508- Setup : func (t * testing.T , ctx context.Context , cm * shared.ClientsMock , cf * shared.ClientFactory ) {
509- cm .AddDefaultMocks ()
510- setupAppLinkCommandMocks (t , ctx , cm , cf )
511- // Set manifest source to project to trigger confirmation prompt
512- if err := config .SetManifestSource (ctx , cm .Fs , cm .Os , config .ManifestSourceLocal ); err != nil {
513- require .FailNow (t , fmt .Sprintf ("Failed to set the manifest source in the memory-based file system: %s" , err ))
514- }
515- // Decline manifest source confirmation prompt
516- cm .IO .On ("ConfirmPrompt" ,
517- mock .Anything ,
518- LinkAppManifestSourceConfirmPromptText ,
519- mock .Anything ,
520- ).Return (false , nil )
521- },
522- CmdArgs : []string {},
523- ExpectedAsserts : func (t * testing.T , ctx context.Context , cm * shared.ClientsMock ) {
524- // Assert manifest confirmation prompt accepted
525- cm .IO .AssertCalled (t , "ConfirmPrompt" ,
526- mock .Anything ,
527- LinkAppManifestSourceConfirmPromptText ,
528- mock .Anything ,
529- )
530-
531- // Assert no apps saved
532- apps , _ , err := cm .AppClient .GetDeployedAll (ctx )
533- require .NoError (t , err )
534- require .Len (t , apps , 0 )
535-
536- apps , err = cm .AppClient .GetLocalAll (ctx )
537- require .NoError (t , err )
538- require .Len (t , apps , 0 )
539- },
540- },
541- "manifest source prompt should not display for Run-on-Slack apps with local manifest source" : {
542- Setup : func (t * testing.T , ctx context.Context , cm * shared.ClientsMock , cf * shared.ClientFactory ) {
543- cm .Auth .On ("Auths" , mock .Anything ).Return ([]types.SlackAuth {
544- mockLinkSlackAuth1 ,
545- mockLinkSlackAuth2 ,
546- }, nil )
547- cm .AddDefaultMocks ()
548- setupAppLinkCommandMocks (t , ctx , cm , cf )
549442 // Set manifest source to local
550443 if err := config .SetManifestSource (ctx , cm .Fs , cm .Os , config .ManifestSourceLocal ); err != nil {
551444 require .FailNow (t , fmt .Sprintf ("Failed to set the manifest source in the memory-based file system: %s" , err ))
552445 }
553- // Mock manifest for Run-on-Slack app
554- manifestMock := & app.ManifestMockObject {}
555- manifestMock .On ("GetManifestLocal" , mock .Anything , mock .Anything , mock .Anything ).Return (types.SlackYaml {
556- AppManifest : types.AppManifest {
557- Settings : & types.AppSettings {
558- FunctionRuntime : types .SlackHosted ,
559- },
560- },
561- }, nil )
562- cf .AppClient ().Manifest = manifestMock
563446 cm .IO .On ("SelectPrompt" ,
564447 mock .Anything ,
565448 "Select the existing app team" ,
@@ -583,7 +466,7 @@ func Test_Apps_Link(t *testing.T) {
583466 mock .Anything ,
584467 ).Return (iostreams.SelectPromptResponse {
585468 Flag : true ,
586- Option : "deployed " ,
469+ Option : "local " ,
587470 }, nil )
588471 cm .API .On (
589472 "GetAppStatus" ,
@@ -600,42 +483,33 @@ func Test_Apps_Link(t *testing.T) {
600483 TeamDomain : mockLinkSlackAuth1 .TeamDomain ,
601484 TeamID : mockLinkSlackAuth1 .TeamID ,
602485 EnterpriseID : mockLinkSlackAuth1 .EnterpriseID ,
486+ UserID : mockLinkSlackAuth1 .UserID ,
487+ IsDev : true ,
603488 }
604- actualApp , err := cm .AppClient .GetDeployed (
489+ actualApp , err := cm .AppClient .GetLocal (
605490 ctx ,
606491 mockLinkSlackAuth1 .TeamID ,
607492 )
608493 require .NoError (t , err )
609494 assert .Equal (t , expectedApp , actualApp )
610- // Assert manifest confirmation prompt was not displayed
611- cm .IO .AssertNotCalled (t , "ConfirmPrompt" ,
612- mock .Anything ,
613- LinkAppManifestSourceConfirmPromptText ,
614- mock .Anything ,
615- )
495+ // Assert manifest source info is displayed
496+ output := cm .GetCombinedOutput ()
497+ assert .Contains (t , output , "App Manifest" )
498+ assert .Contains (t , output , `"project" (local)` )
616499 },
617500 },
618- "manifest source prompt should display for GBP apps with local manifest source" : {
501+ "links app when manifest source is remote " : {
619502 Setup : func (t * testing.T , ctx context.Context , cm * shared.ClientsMock , cf * shared.ClientFactory ) {
620503 cm .Auth .On ("Auths" , mock .Anything ).Return ([]types.SlackAuth {
621- mockLinkSlackAuth1 ,
622504 mockLinkSlackAuth2 ,
505+ mockLinkSlackAuth1 ,
623506 }, nil )
624507 cm .AddDefaultMocks ()
625508 setupAppLinkCommandMocks (t , ctx , cm , cf )
626- // Set manifest source to local
627- if err := config .SetManifestSource (ctx , cm .Fs , cm .Os , config .ManifestSourceLocal ); err != nil {
509+ // Set manifest source to remote
510+ if err := config .SetManifestSource (ctx , cm .Fs , cm .Os , config .ManifestSourceRemote ); err != nil {
628511 require .FailNow (t , fmt .Sprintf ("Failed to set the manifest source in the memory-based file system: %s" , err ))
629512 }
630- // Mock manifest for Run-on-Slack app
631- manifestMock := & app.ManifestMockObject {}
632- manifestMock .On ("GetManifestLocal" , mock .Anything , mock .Anything , mock .Anything ).Return (types.SlackYaml {}, nil )
633- cf .AppClient ().Manifest = manifestMock
634- cm .IO .On ("ConfirmPrompt" ,
635- mock .Anything ,
636- LinkAppManifestSourceConfirmPromptText ,
637- mock .Anything ,
638- ).Return (true , nil )
639513 cm .IO .On ("SelectPrompt" ,
640514 mock .Anything ,
641515 "Select the existing app team" ,
@@ -659,7 +533,7 @@ func Test_Apps_Link(t *testing.T) {
659533 mock .Anything ,
660534 ).Return (iostreams.SelectPromptResponse {
661535 Flag : true ,
662- Option : "deployed " ,
536+ Option : "local " ,
663537 }, nil )
664538 cm .API .On (
665539 "GetAppStatus" ,
@@ -676,19 +550,19 @@ func Test_Apps_Link(t *testing.T) {
676550 TeamDomain : mockLinkSlackAuth1 .TeamDomain ,
677551 TeamID : mockLinkSlackAuth1 .TeamID ,
678552 EnterpriseID : mockLinkSlackAuth1 .EnterpriseID ,
553+ UserID : mockLinkSlackAuth1 .UserID ,
554+ IsDev : true ,
679555 }
680- actualApp , err := cm .AppClient .GetDeployed (
556+ actualApp , err := cm .AppClient .GetLocal (
681557 ctx ,
682558 mockLinkSlackAuth1 .TeamID ,
683559 )
684560 require .NoError (t , err )
685561 assert .Equal (t , expectedApp , actualApp )
686- // Assert manifest confirmation prompt was displayed
687- cm .IO .AssertCalled (t , "ConfirmPrompt" ,
688- mock .Anything ,
689- LinkAppManifestSourceConfirmPromptText ,
690- mock .Anything ,
691- )
562+ // Assert manifest source info is displayed
563+ output := cm .GetCombinedOutput ()
564+ assert .Contains (t , output , "App Manifest" )
565+ assert .Contains (t , output , `"app settings" (remote)` )
692566 },
693567 },
694568 }, func (clients * shared.ClientFactory ) * cobra.Command {
0 commit comments