Skip to content

Commit 938eb71

Browse files
authored
tests: test in parallel (#593)
1 parent 5a7d96e commit 938eb71

File tree

10 files changed

+203
-120
lines changed

10 files changed

+203
-120
lines changed

internal/cli/alerts/acknowledge_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ func TestAcknowledgeOpts_Run(t *testing.T) {
8787
opts := tt.opts
8888
wantErr := tt.wantErr
8989
t.Run(tt.name, func(t *testing.T) {
90+
t.Parallel()
9091
ackReq := opts.newAcknowledgeRequest()
9192
if wantErr {
9293
mockStore.

internal/cli/atlas/dbusers/create_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ func TestCreateOpts_validate(t *testing.T) {
184184
fields := tt.fields
185185
wantErr := tt.wantErr
186186
t.Run(tt.name, func(t *testing.T) {
187+
t.Parallel()
187188
opts := &CreateOpts{
188189
x509Type: fields.x509Type,
189190
awsIamType: fields.awsIamType,

internal/cli/atlas/logs/download_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ func TestDownloadOpts_initDefaultOut(t *testing.T) {
9191
out := tt.fields.out
9292
want := tt.want
9393
t.Run(tt.name, func(t *testing.T) {
94+
t.Parallel()
9495
opts := &DownloadOpts{
9596
name: logName,
9697
}

internal/cli/global_opts_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ func TestGenerateAliases(t *testing.T) {
119119
want := tt.want
120120
args := tt.args
121121
t.Run(tt.name, func(t *testing.T) {
122+
t.Parallel()
122123
got := GenerateAliases(args.use, args.extra...)
123124
assert.Equal(t, got, want)
124125
})

internal/cli/output_opts_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ func TestOutputOpts_outputTypeAndValue(t *testing.T) {
5656
}
5757
want := tt.want
5858
t.Run(tt.name, func(t *testing.T) {
59+
t.Parallel()
5960
_, got := opts.outputTypeAndValue()
6061
if got != want {
6162
t.Errorf("parseTemplate() got = %v, want %v", got, want)

internal/convert/automation_config_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
func TestFromAutomationConfig(t *testing.T) {
2828
name := "cluster_1"
2929
t.Run("replica set", func(t *testing.T) {
30+
t.Parallel()
3031
config := fixture.AutomationConfigWithOneReplicaSet(name, false)
3132
expected := []*ClusterConfig{
3233
{
@@ -82,6 +83,7 @@ func TestFromAutomationConfig(t *testing.T) {
8283
}
8384
})
8485
t.Run("sharded cluster", func(t *testing.T) {
86+
t.Parallel()
8587
config := fixture.AutomationConfigWithOneShardedCluster(name, false)
8688
expected := []*ClusterConfig{
8789
{

internal/convert/cluster_config_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,7 @@ func TestClusterConfig_PatchAutomationConfig(t *testing.T) {
958958
current := tc.current
959959
expected := tc.expected
960960
t.Run(name, func(t *testing.T) {
961+
t.Parallel()
961962
if err := changes.PatchAutomationConfig(current); err != nil {
962963
t.Fatalf("PatchAutomationConfig() unexpected error: %v\n", err)
963964
}

internal/convert/custom_db_role_test.go

Lines changed: 82 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -30,35 +30,49 @@ func TestBuildAtlasInheritedRoles(t *testing.T) {
3030
}
3131

3232
tests := []test{
33-
{input: []string{"admin"}, want: []mongodbatlas.InheritedRole{
34-
{
35-
Role: "admin",
36-
Db: "admin",
37-
}},
33+
{
34+
input: []string{"admin"},
35+
want: []mongodbatlas.InheritedRole{
36+
{
37+
Role: "admin",
38+
Db: "admin",
39+
},
40+
},
3841
},
39-
{input: []string{"admin@test"}, want: []mongodbatlas.InheritedRole{
40-
{
41-
Role: "admin",
42-
Db: "test",
43-
}},
42+
{
43+
input: []string{"admin@test"},
44+
want: []mongodbatlas.InheritedRole{
45+
{
46+
Role: "admin",
47+
Db: "test",
48+
},
49+
},
4450
},
45-
{input: []string{"admin@test", "something"}, want: []mongodbatlas.InheritedRole{
46-
{
47-
Role: "admin",
48-
Db: "test",
51+
{
52+
input: []string{"admin@test", "something"},
53+
want: []mongodbatlas.InheritedRole{
54+
{
55+
Role: "admin",
56+
Db: "test",
57+
},
58+
{
59+
Role: "something",
60+
Db: "admin",
61+
},
4962
},
50-
{
51-
Role: "something",
52-
Db: "admin",
53-
}},
5463
},
5564
}
5665

5766
for _, tc := range tests {
58-
got := BuildAtlasInheritedRoles(tc.input)
59-
if err := deep.Equal(tc.want, got); err != nil {
60-
t.Fatalf("expected: %v, got: %v", tc.want, got)
61-
}
67+
input := tc.input
68+
want := tc.want
69+
t.Run("", func(t *testing.T) {
70+
t.Parallel()
71+
got := BuildAtlasInheritedRoles(input)
72+
if err := deep.Equal(want, got); err != nil {
73+
t.Fatalf("expected: %v, got: %v", want, got)
74+
}
75+
})
6276
}
6377
}
6478

@@ -71,51 +85,65 @@ func TestBuildAtlasActions(t *testing.T) {
7185
cluster := true
7286

7387
tests := []test{
74-
{input: []string{"clusterName"}, want: []mongodbatlas.Action{
75-
{
76-
Action: "clusterName",
77-
Resources: []mongodbatlas.Resource{
78-
{
79-
Cluster: &cluster,
88+
{
89+
input: []string{"clusterName"},
90+
want: []mongodbatlas.Action{
91+
{
92+
Action: "clusterName",
93+
Resources: []mongodbatlas.Resource{
94+
{
95+
Cluster: &cluster,
96+
},
8097
},
8198
},
8299
},
83-
}},
84-
{input: []string{"[email protected]"}, want: []mongodbatlas.Action{
85-
{
86-
Action: "clusterName",
87-
Resources: []mongodbatlas.Resource{
88-
{
89-
Db: "testdb",
90-
Collection: "collection",
100+
},
101+
{
102+
input: []string{"[email protected]"},
103+
want: []mongodbatlas.Action{
104+
{
105+
Action: "clusterName",
106+
Resources: []mongodbatlas.Resource{
107+
{
108+
Db: "testdb",
109+
Collection: "collection",
110+
},
91111
},
92112
},
93113
},
94-
}},
95-
{input: []string{"clusterName", "name@DATA_LAKE"}, want: []mongodbatlas.Action{
96-
{
97-
Action: "clusterName",
98-
Resources: []mongodbatlas.Resource{
99-
{
100-
Cluster: &cluster,
114+
},
115+
{
116+
input: []string{"clusterName", "name@DATA_LAKE"},
117+
want: []mongodbatlas.Action{
118+
{
119+
Action: "clusterName",
120+
Resources: []mongodbatlas.Resource{
121+
{
122+
Cluster: &cluster,
123+
},
101124
},
102125
},
103-
},
104-
{
105-
Action: "name",
106-
Resources: []mongodbatlas.Resource{
107-
{
108-
Db: "DATA_LAKE",
126+
{
127+
Action: "name",
128+
Resources: []mongodbatlas.Resource{
129+
{
130+
Db: "DATA_LAKE",
131+
},
109132
},
110133
},
111134
},
112-
}},
135+
},
113136
}
114137

115138
for _, tc := range tests {
116-
got := BuildAtlasActions(tc.input)
117-
if err := deep.Equal(tc.want, got); err != nil {
118-
t.Fatalf("expected: %v, got: %v", tc.want, got)
119-
}
139+
input := tc.input
140+
want := tc.want
141+
t.Run("", func(t *testing.T) {
142+
t.Parallel()
143+
got := BuildAtlasActions(input)
144+
if err := deep.Equal(want, got); err != nil {
145+
t.Fatalf("expected: %v, got: %v", want, got)
146+
}
147+
})
120148
}
121149
}

internal/convert/rs_config_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ func TestRSConfig_protocolVer(t *testing.T) {
5656
expected := tc.wantedProtocolVersion
5757
wantErr := tc.wantErr
5858
t.Run(name, func(t *testing.T) {
59+
t.Parallel()
5960
ver, err := m.protocolVer()
6061
if (err != nil) != wantErr {
6162
t.Fatalf("protocolVer() unexpected error: %v\n", err)

0 commit comments

Comments
 (0)