Skip to content

Commit

Permalink
Revert "Create org as part of new user creation in tests"
Browse files Browse the repository at this point in the history
This reverts commit b2e9bf2.
  • Loading branch information
Naatan committed Aug 31, 2023
1 parent e2bdc7a commit f414c88
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 94 deletions.
7 changes: 1 addition & 6 deletions cmd/state/internal/cmdtree/cmdtree.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,6 @@ func New(prime *primer.Values, args ...string) *CmdTree {

refreshCmd := newRefreshCommand(prime)

orgCmd := newOrganizationsCommand(prime)
orgCmd.AddChildren(
newOrganizationsAddCommand(prime),
)

stateCmd := newStateCommand(globals, prime)
stateCmd.AddChildren(
newHelloCommand(prime),
Expand All @@ -171,7 +166,7 @@ func New(prime *primer.Values, args ...string) *CmdTree {
projectsCmd,
authCmd,
exportCmd,
orgCmd,
newOrganizationsCommand(prime),
newRunCommand(prime),
newShowCommand(prime),
installCmd,
Expand Down
30 changes: 0 additions & 30 deletions cmd/state/internal/cmdtree/organizations.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,33 +30,3 @@ func newOrganizationsCommand(prime *primer.Values) *captain.Command {

return cmd
}

func newOrganizationsAddCommand(prime *primer.Values) *captain.Command {
runner := organizations.NewOrganizationsAdd(prime)

params := organizations.OrgAddParams{}

cmd := captain.NewCommand(
"add",
locale.Tl("organizations_add_title", "Creating Organization"),
locale.T("organizations_add_description"),
prime,
[]*captain.Flag{},
[]*captain.Argument{
{
Name: locale.Tl("organizations_add_name", "Name"),
Description: locale.Tl("organizations_add_name_description", "The name of the organization"),
Required: true,
Value: &params.Name,
},
},
func(ccmd *captain.Command, _ []string) error {
return runner.Run(&params)
},
)

cmd.SetUnstable(true)
cmd.SetHidden(true) // for test use only at this time

return cmd
}
2 changes: 0 additions & 2 deletions internal/locale/locales/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,6 @@ organization:
other: Organization
organizations_description:
other: List member organizations on the ActiveState Platform
organizations_add_description:
other: Add a new organization to the ActiveState Platform
organizations_err:
other: Unable to list member organizations
organizations_unknown_tier:
Expand Down
27 changes: 0 additions & 27 deletions internal/runners/organizations/add.go

This file was deleted.

9 changes: 1 addition & 8 deletions internal/testhelpers/e2e/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ func (s *Session) CreateNewUser() (string, string) {
password := uid.String()[8:]
email := fmt.Sprintf("%[email protected]", username)

p := s.Spawn("auth", "signup", "--prompt")
p := s.Spawn(tagsuite.Auth, "signup", "--prompt")

p.Expect("I accept")
p.SendLine("")
Expand All @@ -396,16 +396,9 @@ func (s *Session) CreateNewUser() (string, string) {

s.users = append(s.users, username)

s.CreateOrg(username) // Many of our tests rely on this implicitly also creating an org as that's how the API used to behave

return username, password
}

func (s *Session) CreateOrg(name string) {
p := s.Spawn("organizations", "add", name)
p.ExpectExitCode(0)
}

// NotifyProjectCreated indicates that the given project was created on the Platform and needs to
// be deleted when the session is closed.
// This only needs to be called for projects created by PersistentUsername, not projects created by
Expand Down
21 changes: 0 additions & 21 deletions pkg/platform/model/organizations.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,6 @@ import (

var ErrMemberNotFound = errs.New("member not found")

func CreateOrg(name string) error {
params := clientOrgs.NewAddOrganizationParams()
params.Organization = &mono_models.OrganizationEditable{
URLname: name,
DisplayName: name,
}
_, err := authentication.Client().Organizations.AddOrganization(params, authentication.ClientAuth())
if err != nil {
switch statusCode := api.ErrorCode(err); statusCode {
case 400:
return locale.WrapInputError(err, "", err.Error())
case 403:
return locale.WrapInputError(err, "err_auth_required")
case 409:
return locale.WrapInputError(err, "err_organization_add_exists", "Organization name already exists")
}
return errs.Wrap(err, "failed to create organization")
}
return nil
}

// FetchOrganizations fetches all organizations for the current user.
func FetchOrganizations() ([]*mono_models.Organization, error) {
params := clientOrgs.NewListOrganizationsParams()
Expand Down

0 comments on commit f414c88

Please sign in to comment.