Skip to content

Commit

Permalink
CLOUDP-70843: Add e2e tests for project and org user list (#400)
Browse files Browse the repository at this point in the history
  • Loading branch information
gssbzn committed Sep 2, 2020
1 parent 92e3c25 commit b0aea79
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 12 deletions.
14 changes: 14 additions & 0 deletions e2e/iam/orgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,18 @@ func TestOrgs(t *testing.T) {
resp, err := cmd.CombinedOutput()
assert.NoError(t, err, string(resp))
})

t.Run("Users", func(t *testing.T) {
cmd := exec.Command(cliPath,
iamEntity,
orgEntity,
usersEntity,
"ls",
"--orgId",
orgID,
"-o=json")
cmd.Env = os.Environ()
resp, err := cmd.CombinedOutput()
assert.NoError(t, err, string(resp))
})
}
31 changes: 19 additions & 12 deletions e2e/iam/projects_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"testing"

"github.com/mongodb/mongocli/e2e"
"github.com/stretchr/testify/assert"
"go.mongodb.org/atlas/mongodbatlas"
)

Expand Down Expand Up @@ -50,9 +51,7 @@ func TestProjects(t *testing.T) {
cmd.Env = os.Environ()
resp, err := cmd.CombinedOutput()

if err != nil {
t.Fatalf("unexpected error: %v, resp: %v", err, string(resp))
}
assert.NoError(t, err, string(resp))

var project mongodbatlas.Project
if err = json.Unmarshal(resp, &project); err != nil {
Expand All @@ -74,9 +73,7 @@ func TestProjects(t *testing.T) {
cmd.Env = os.Environ()
resp, err := cmd.CombinedOutput()

if err != nil {
t.Fatalf("unexpected error: %v, resp: %v", err, string(resp))
}
assert.NoError(t, err, string(resp))
})

t.Run("Describe", func(t *testing.T) {
Expand All @@ -89,9 +86,21 @@ func TestProjects(t *testing.T) {
cmd.Env = os.Environ()
resp, err := cmd.CombinedOutput()

if err != nil {
t.Fatalf("unexpected error: %v, resp: %v", err, string(resp))
}
assert.NoError(t, err, string(resp))
})

t.Run("Users", func(t *testing.T) {
cmd := exec.Command(cliPath,
iamEntity,
projectEntity,
usersEntity,
"ls",
"--projectId",
projectID,
"-o=json")
cmd.Env = os.Environ()
resp, err := cmd.CombinedOutput()
assert.NoError(t, err, string(resp))
})

t.Run("Delete", func(t *testing.T) {
Expand All @@ -104,9 +113,7 @@ func TestProjects(t *testing.T) {
cmd.Env = os.Environ()
resp, err := cmd.CombinedOutput()

if err != nil {
t.Fatalf("unexpected error: %v, resp: %v", err, string(resp))
}
assert.NoError(t, err, string(resp))

expected := fmt.Sprintf("Project '%s' deleted\n", projectID)
if string(resp) != expected {
Expand Down

0 comments on commit b0aea79

Please sign in to comment.