diff --git a/cloud/organization/organization.go b/cloud/organization/organization.go index 238f82c61..55477fec2 100644 --- a/cloud/organization/organization.go +++ b/cloud/organization/organization.go @@ -17,11 +17,12 @@ import ( ) var ( - errInvalidOrganizationKey = errors.New("invalid organization selection") - errInvalidOrganizationName = errors.New("invalid organization name") - Login = auth.Login - CheckUserSession = auth.CheckUserSession - FetchDomainAuthConfig = auth.FetchDomainAuthConfig + errInvalidOrganizationKey = errors.New("invalid organization selection") + errInvalidOrganizationName = errors.New("invalid organization name") + Login = auth.Login + CheckUserSession = auth.CheckUserSession + FetchDomainAuthConfig = auth.FetchDomainAuthConfig + switchedOrganizationMessage = "\nSuccessfully switched organization" ) func newTableOut() *printutil.Table { @@ -122,7 +123,12 @@ func SwitchWithContext(domain string, targetOrg *astrocore.Organization, astroCl _ = c.SetContextKey("user_email", c.UserEmail) c, _ = context.GetCurrentContext() // call check user session which will trigger workspace switcher flow - return CheckUserSession(&c, astroClient, coreClient, out) + err := CheckUserSession(&c, astroClient, coreClient, out) + if err != nil { + return err + } + fmt.Fprintln(out, switchedOrganizationMessage) + return nil } // Switch switches organizations diff --git a/cloud/organization/organization_test.go b/cloud/organization/organization_test.go index 40441f8c4..7d8d747ac 100644 --- a/cloud/organization/organization_test.go +++ b/cloud/organization/organization_test.go @@ -164,6 +164,7 @@ func TestSwitch(t *testing.T) { buf := new(bytes.Buffer) err := Switch("org1", mockGQLClient, mockCoreClient, buf, false) assert.NoError(t, err) + assert.Equal(t, "\nSuccessfully switched organization\n", buf.String()) mockCoreClient.AssertExpectations(t) })