Skip to content

Commit 81955bf

Browse files
CLOUDP-62815: add e2e test events - cloud manager (#178)
1 parent b547a41 commit 81955bf

File tree

1 file changed

+101
-0
lines changed

1 file changed

+101
-0
lines changed

e2e/cloud_manager/events_test.go

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
// Copyright 2020 MongoDB Inc
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
// +build e2e
15+
16+
package cloud_manager_test
17+
18+
import (
19+
"encoding/json"
20+
"os"
21+
"os/exec"
22+
"path/filepath"
23+
"testing"
24+
25+
"github.com/mongodb/go-client-mongodb-atlas/mongodbatlas"
26+
)
27+
28+
func TestCloudManagerEvents(t *testing.T) {
29+
cliPath, err := filepath.Abs("../../bin/mongocli")
30+
if err != nil {
31+
t.Fatalf("unexpected error: %v", err)
32+
}
33+
_, err = os.Stat(cliPath)
34+
35+
if err != nil {
36+
t.Fatalf("unexpected error: %v", err)
37+
}
38+
39+
cloudManagerEntity := "cm"
40+
eventsEntity := "events"
41+
42+
t.Run("ListProjectEvent", func(t *testing.T) {
43+
44+
cmd := exec.Command(cliPath,
45+
cloudManagerEntity,
46+
eventsEntity,
47+
"list",
48+
"--projectId=5ec2839e74c5aa25f02ff8ee",
49+
)
50+
51+
cmd.Env = os.Environ()
52+
resp, err := cmd.CombinedOutput()
53+
54+
if err != nil {
55+
t.Fatalf("unexpected error: %v, resp: %v", err, string(resp))
56+
}
57+
58+
events := mongodbatlas.EventResponse{}
59+
err = json.Unmarshal(resp, &events)
60+
61+
if err != nil {
62+
t.Fatalf("unexpected error: %v", err)
63+
}
64+
65+
if len(events.Results) == 0 {
66+
t.Errorf("got=%#v\nwant>0\n", len(events.Results))
67+
}
68+
69+
})
70+
71+
t.Run("ListOrganizationEvent", func(t *testing.T) {
72+
73+
cmd := exec.Command(cliPath,
74+
cloudManagerEntity,
75+
eventsEntity,
76+
"list",
77+
"--orgId=5ec2836d74c5aa25f02ff8c9",
78+
"--minDate=2020-04-01",
79+
)
80+
81+
cmd.Env = os.Environ()
82+
resp, err := cmd.CombinedOutput()
83+
84+
if err != nil {
85+
t.Fatalf("unexpected error: %v, resp: %v", err, string(resp))
86+
}
87+
88+
events := mongodbatlas.EventResponse{}
89+
err = json.Unmarshal(resp, &events)
90+
91+
if err != nil {
92+
t.Fatalf("unexpected error: %v", err)
93+
}
94+
95+
if len(events.Results) == 0 {
96+
t.Errorf("got=%#v\nwant>0\n", len(events.Results))
97+
}
98+
99+
})
100+
101+
}

0 commit comments

Comments
 (0)