7
7
"time"
8
8
)
9
9
10
+ // nolint:paralleltest
11
+ // t.Setenv doesn't work with t.Parallel()
10
12
func TestConfigurator (t * testing.T ) {
11
13
// setting command line flag
12
14
os .Args = []string {"smth" , "-name=flag_value" }
@@ -83,6 +85,8 @@ func TestConfigurator(t *testing.T) {
83
85
}
84
86
85
87
func TestConfigurator_Errors (t * testing.T ) {
88
+ t .Parallel ()
89
+
86
90
tests := map [string ]struct {
87
91
input any
88
92
providers []Provider
@@ -102,6 +106,8 @@ func TestConfigurator_Errors(t *testing.T) {
102
106
for name , test := range tests {
103
107
test := test
104
108
t .Run (name , func (t * testing.T ) {
109
+ t .Parallel ()
110
+
105
111
err := New (test .input , test .providers ... ).InitValues ()
106
112
if err == nil {
107
113
t .Fatal ("expected error but got nil" )
@@ -111,6 +117,8 @@ func TestConfigurator_Errors(t *testing.T) {
111
117
}
112
118
113
119
func TestEmbeddedFlags (t * testing.T ) {
120
+ t .Parallel ()
121
+
114
122
type (
115
123
Client struct {
116
124
ServerAddress string `flag:"addr|127.0.0.1:443|server address"`
@@ -130,6 +138,7 @@ func TestEmbeddedFlags(t *testing.T) {
130
138
assert (t , cfg .Client .ServerAddress , "addr_value" )
131
139
}
132
140
141
+ // nolint:paralleltest
133
142
func TestFallBackToDefault (t * testing.T ) {
134
143
// defining a struct
135
144
cfg := struct {
@@ -149,6 +158,8 @@ func TestFallBackToDefault(t *testing.T) {
149
158
}
150
159
151
160
func TestSetOnFailFn (t * testing.T ) {
161
+ t .Parallel ()
162
+
152
163
cfg := struct {
153
164
Name string `default:"test_name"`
154
165
}{}
@@ -172,6 +183,8 @@ func TestSetOnFailFn(t *testing.T) {
172
183
}
173
184
174
185
func TestProviderName (t * testing.T ) {
186
+ t .Parallel ()
187
+
175
188
testCases := map [string ]struct {
176
189
provider Provider
177
190
expectedName string
@@ -198,21 +211,29 @@ func TestProviderName(t *testing.T) {
198
211
test := test
199
212
200
213
t .Run (name , func (t * testing.T ) {
214
+ t .Parallel ()
215
+
201
216
assert (t , test .expectedName , test .provider .Name ())
202
217
})
203
218
}
204
219
}
205
220
206
221
func TestConfigurator_NameCollision (t * testing.T ) {
222
+ t .Parallel ()
223
+
207
224
err := New (& struct {}{}, NewDefaultProvider (), NewDefaultProvider ()).InitValues ()
208
225
assert (t , ErrProviderNameCollision , err )
209
226
}
210
227
211
228
func TestConfigurator_FailedProvider (t * testing.T ) {
229
+ t .Parallel ()
230
+
212
231
err := New (& struct {}{}, NewJSONFileProvider ("doesn't exist" )).InitValues ()
213
232
assert (t , "cannot init [JSONFileProvider] provider: JSONFileProvider.Init: open doesn't exist: no such file or directory" , err .Error ())
214
233
}
215
234
235
+ // nolint:paralleltest
236
+ // t.Setenv doesn't work with t.Parallel()
216
237
func Test_FromEnvAndDefault (t * testing.T ) {
217
238
t .Setenv ("AGE" , "24" )
218
239
0 commit comments