Skip to content

Commit 3f61ed8

Browse files
committed
tests: improve cluster e2e testing
1 parent 64a75f1 commit 3f61ed8

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

e2e/atlas/clusters_test.go

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ import (
3030

3131
func TestClustersFlags(t *testing.T) {
3232
cliPath, err := e2e.Bin()
33-
a := assert.New(t)
3433
req := require.New(t)
3534
req.NoError(err)
35+
3636
clusterName, err := RandClusterName()
3737
req.NoError(err)
3838

@@ -56,7 +56,7 @@ func TestClustersFlags(t *testing.T) {
5656

5757
var cluster *mongodbatlas.Cluster
5858
err = json.Unmarshal(resp, &cluster)
59-
a.NoError(err)
59+
req.NoError(err)
6060

6161
ensureCluster(t, cluster, clusterName, "4.0", 10)
6262
})
@@ -71,6 +71,8 @@ func TestClustersFlags(t *testing.T) {
7171
cmd.Env = os.Environ()
7272
resp, err := cmd.CombinedOutput()
7373
req.NoError(err)
74+
75+
a := assert.New(t)
7476
a.Contains(string(resp), "Cluster available")
7577
})
7678

@@ -87,6 +89,8 @@ func TestClustersFlags(t *testing.T) {
8789
var clusters []mongodbatlas.Cluster
8890
err = json.Unmarshal(resp, &clusters)
8991
req.NoError(err)
92+
93+
a := assert.New(t)
9094
a.NotEmpty(clusters)
9195
})
9296

@@ -104,6 +108,8 @@ func TestClustersFlags(t *testing.T) {
104108
var cluster mongodbatlas.Cluster
105109
err = json.Unmarshal(resp, &cluster)
106110
req.NoError(err)
111+
112+
a := assert.New(t)
107113
a.Equal(clusterName, cluster.Name)
108114
})
109115

@@ -123,6 +129,7 @@ func TestClustersFlags(t *testing.T) {
123129
err = json.Unmarshal(resp, &connectionString)
124130
req.NoError(err)
125131

132+
a := assert.New(t)
126133
a.NotEmpty(connectionString.Standard)
127134
a.NotEmpty(connectionString.StandardSrv)
128135
})
@@ -169,17 +176,18 @@ func TestClustersFlags(t *testing.T) {
169176
req.NoError(err)
170177

171178
expected := fmt.Sprintf("Cluster '%s' deleted\n", clusterName)
179+
a := assert.New(t)
172180
a.Equal(expected, string(resp))
173181
})
174182
}
175183

176184
func TestClustersFile(t *testing.T) {
177185
cliPath, err := e2e.Bin()
178-
a := assert.New(t)
179-
a.NoError(err)
186+
req := require.New(t)
187+
req.NoError(err)
180188

181189
clusterFileName, err := RandClusterName()
182-
a.NoError(err)
190+
req.NoError(err)
183191

184192
t.Run("Create via file", func(t *testing.T) {
185193
cmd := exec.Command(cliPath,
@@ -191,11 +199,11 @@ func TestClustersFile(t *testing.T) {
191199
"-o=json")
192200
cmd.Env = os.Environ()
193201
resp, err := cmd.CombinedOutput()
194-
a.NoError(err)
202+
req.NoError(err)
195203

196204
var cluster mongodbatlas.Cluster
197205
err = json.Unmarshal(resp, &cluster)
198-
a.NoError(err)
206+
req.NoError(err)
199207

200208
ensureCluster(t, &cluster, clusterFileName, "4.2", 10)
201209
})
@@ -210,11 +218,11 @@ func TestClustersFile(t *testing.T) {
210218
"-o=json")
211219
cmd.Env = os.Environ()
212220
resp, err := cmd.CombinedOutput()
213-
a.NoError(err)
221+
req.NoError(err)
214222

215223
var cluster mongodbatlas.Cluster
216224
err = json.Unmarshal(resp, &cluster)
217-
a.NoError(err)
225+
req.NoError(err)
218226

219227
ensureCluster(t, &cluster, clusterFileName, "4.2", 25)
220228
})
@@ -223,9 +231,10 @@ func TestClustersFile(t *testing.T) {
223231
cmd := exec.Command(cliPath, atlasEntity, clustersEntity, "delete", clusterFileName, "--force")
224232
cmd.Env = os.Environ()
225233
resp, err := cmd.CombinedOutput()
226-
a.NoError(err)
234+
req.NoError(err)
227235

228236
expected := fmt.Sprintf("Cluster '%s' deleted\n", clusterFileName)
237+
a := assert.New(t)
229238
a.Equal(expected, string(resp))
230239
})
231240
}

0 commit comments

Comments
 (0)