Skip to content

Commit f4c41b6

Browse files
committed
fix: linting problem
1 parent 6ec1fb8 commit f4c41b6

File tree

2 files changed

+107
-108
lines changed

2 files changed

+107
-108
lines changed

pkg/es/config/config_test.go

Lines changed: 106 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ func copyToTempFile(t *testing.T, pattern string, filename string) (file *os.Fil
7070

7171
func TestNewClient(t *testing.T) {
7272
const (
73-
pwd1 = "password"
74-
token = "token"
73+
pwd1 = "password"
74+
token = "token"
7575
serverCert = "../../config/tlscfg/testdata/example-server-cert.pem"
7676
)
7777
pwdFile := filepath.Join(t.TempDir(), "pwd")
@@ -81,7 +81,6 @@ func TestNewClient(t *testing.T) {
8181
// copy certs to temp so we can modify them
8282
certFilePath := copyToTempFile(t, "cert.crt", serverCert)
8383

84-
8584
testServer := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
8685
require.Equal(t, http.MethodGet, req.Method)
8786
res.WriteHeader(http.StatusOK)
@@ -108,7 +107,7 @@ func TestNewClient(t *testing.T) {
108107
defer testServer8.Close()
109108
tests := []struct {
110109
name string
111-
config *Configuration
110+
config *Configuration
112111
expectedError bool
113112
}{
114113
{
@@ -128,164 +127,164 @@ func TestNewClient(t *testing.T) {
128127
{
129128
name: "success with valid configuration and tls enabled",
130129
config: &Configuration{
131-
Servers: []string{testServer.URL},
132-
AllowTokenFromContext: true,
133-
Password: "secret",
134-
LogLevel: "debug",
135-
Username: "user",
136-
PasswordFilePath: "",
137-
BulkSize: -1, // disable bulk; we want immediate flush
138-
Version: 8,
139-
TLS: tlscfg.Options{Enabled: true},
140-
},
130+
Servers: []string{testServer.URL},
131+
AllowTokenFromContext: true,
132+
Password: "secret",
133+
LogLevel: "debug",
134+
Username: "user",
135+
PasswordFilePath: "",
136+
BulkSize: -1, // disable bulk; we want immediate flush
137+
Version: 8,
138+
TLS: tlscfg.Options{Enabled: true},
139+
},
141140
expectedError: false,
142141
},
143142
{
144143
name: "success with valid configuration and reading token and certicate from file",
145144
config: &Configuration{
146-
Servers: []string{testServer.URL},
147-
AllowTokenFromContext: true,
148-
Password: "secret",
149-
LogLevel: "debug",
150-
Username: "user",
151-
PasswordFilePath: "",
152-
BulkSize: -1, // disable bulk; we want immediate flush
153-
Version: 1,
154-
TLS: tlscfg.Options{Enabled: false, CAPath: certFilePath.Name()},
155-
TokenFilePath: pwdtokenFile,
156-
},
145+
Servers: []string{testServer.URL},
146+
AllowTokenFromContext: true,
147+
Password: "secret",
148+
LogLevel: "debug",
149+
Username: "user",
150+
PasswordFilePath: "",
151+
BulkSize: -1, // disable bulk; we want immediate flush
152+
Version: 1,
153+
TLS: tlscfg.Options{Enabled: false, CAPath: certFilePath.Name()},
154+
TokenFilePath: pwdtokenFile,
155+
},
157156
expectedError: false,
158157
},
159158
{
160159
name: "succes with invalid configuration of version higher than 8",
161160
config: &Configuration{
162-
Servers: []string{testServer8.URL},
163-
AllowTokenFromContext: true,
164-
Password: "secret",
165-
LogLevel: "debug",
166-
Username: "user",
167-
PasswordFilePath: "",
168-
BulkSize: -1, // disable bulk; we want immediate flush
169-
Version: 9,
170-
},
161+
Servers: []string{testServer8.URL},
162+
AllowTokenFromContext: true,
163+
Password: "secret",
164+
LogLevel: "debug",
165+
Username: "user",
166+
PasswordFilePath: "",
167+
BulkSize: -1, // disable bulk; we want immediate flush
168+
Version: 9,
169+
},
171170
expectedError: false,
172171
},
173172
{
174173
name: "success with valid configuration with version 1",
175174
config: &Configuration{
176-
Servers: []string{testServer1.URL},
177-
AllowTokenFromContext: true,
178-
Password: "secret",
179-
LogLevel: "debug",
180-
Username: "user",
181-
PasswordFilePath: "",
182-
BulkSize: -1, // disable bulk; we want immediate flush
183-
},
175+
Servers: []string{testServer1.URL},
176+
AllowTokenFromContext: true,
177+
Password: "secret",
178+
LogLevel: "debug",
179+
Username: "user",
180+
PasswordFilePath: "",
181+
BulkSize: -1, // disable bulk; we want immediate flush
182+
},
184183
expectedError: false,
185184
},
186185
{
187186
name: "success with valid configuration with version 2",
188187
config: &Configuration{
189-
Servers: []string{testServer2.URL},
190-
AllowTokenFromContext: true,
191-
Password: "secret",
192-
LogLevel: "debug",
193-
Username: "user",
194-
PasswordFilePath: "",
195-
BulkSize: -1, // disable bulk; we want immediate flush
196-
},
188+
Servers: []string{testServer2.URL},
189+
AllowTokenFromContext: true,
190+
Password: "secret",
191+
LogLevel: "debug",
192+
Username: "user",
193+
PasswordFilePath: "",
194+
BulkSize: -1, // disable bulk; we want immediate flush
195+
},
197196
expectedError: false,
198197
},
199198
{
200199
name: "success with valid configuration password from file",
201200
config: &Configuration{
202-
Servers: []string{testServer.URL},
203-
AllowTokenFromContext: true,
204-
Password: "",
205-
LogLevel: "debug",
206-
Username: "user",
207-
PasswordFilePath: pwdFile,
208-
BulkSize: -1, // disable bulk; we want immediate flush
209-
},
201+
Servers: []string{testServer.URL},
202+
AllowTokenFromContext: true,
203+
Password: "",
204+
LogLevel: "debug",
205+
Username: "user",
206+
PasswordFilePath: pwdFile,
207+
BulkSize: -1, // disable bulk; we want immediate flush
208+
},
210209
expectedError: false,
211210
},
212211
{
213212
name: "fali with configuration password and password from file are set",
214213
config: &Configuration{
215-
Servers: []string{testServer.URL},
216-
AllowTokenFromContext: true,
217-
Password: "secret",
218-
LogLevel: "debug",
219-
Username: "user",
220-
PasswordFilePath: pwdFile,
221-
BulkSize: -1, // disable bulk; we want immediate flush
222-
},
214+
Servers: []string{testServer.URL},
215+
AllowTokenFromContext: true,
216+
Password: "secret",
217+
LogLevel: "debug",
218+
Username: "user",
219+
PasswordFilePath: pwdFile,
220+
BulkSize: -1, // disable bulk; we want immediate flush
221+
},
223222
expectedError: true,
224223
},
225224
{
226225
name: "fail with missing server",
227226
config: &Configuration{
228-
Servers: []string{},
229-
AllowTokenFromContext: true,
230-
Password: "secret",
231-
LogLevel: "debug",
232-
Username: "user",
233-
PasswordFilePath: "",
234-
BulkSize: -1, // disable bulk; we want immediate flush
235-
},
227+
Servers: []string{},
228+
AllowTokenFromContext: true,
229+
Password: "secret",
230+
LogLevel: "debug",
231+
Username: "user",
232+
PasswordFilePath: "",
233+
BulkSize: -1, // disable bulk; we want immediate flush
234+
},
236235
expectedError: true,
237236
},
238237
{
239238
name: "fail with invalid configuration invalid loglevel",
240239
config: &Configuration{
241-
Servers: []string{testServer.URL},
242-
AllowTokenFromContext: true,
243-
Password: "secret",
244-
LogLevel: "invalid",
245-
Username: "user",
246-
PasswordFilePath: "",
247-
BulkSize: -1, // disable bulk; we want immediate flush
248-
},
240+
Servers: []string{testServer.URL},
241+
AllowTokenFromContext: true,
242+
Password: "secret",
243+
LogLevel: "invalid",
244+
Username: "user",
245+
PasswordFilePath: "",
246+
BulkSize: -1, // disable bulk; we want immediate flush
247+
},
249248
expectedError: true,
250249
},
251250
{
252251
name: "fail with invalid configuration invalid bulkworkers number",
253252
config: &Configuration{
254-
Servers: []string{testServer.URL},
255-
AllowTokenFromContext: true,
256-
Password: "secret",
257-
LogLevel: "invalid",
258-
Username: "user",
259-
PasswordFilePath: "",
260-
BulkWorkers: 0,
261-
BulkSize: -1, // disable bulk; we want immediate flush
262-
},
253+
Servers: []string{testServer.URL},
254+
AllowTokenFromContext: true,
255+
Password: "secret",
256+
LogLevel: "invalid",
257+
Username: "user",
258+
PasswordFilePath: "",
259+
BulkWorkers: 0,
260+
BulkSize: -1, // disable bulk; we want immediate flush
261+
},
263262
expectedError: true,
264263
},
265264
{
266265
name: "success with valid configuration and info log level",
267266
config: &Configuration{
268-
Servers: []string{testServer.URL},
269-
AllowTokenFromContext: true,
270-
Password: "secret",
271-
LogLevel: "info",
272-
Username: "user",
273-
PasswordFilePath: "",
274-
BulkSize: -1, // disable bulk; we want immediate flush
275-
},
267+
Servers: []string{testServer.URL},
268+
AllowTokenFromContext: true,
269+
Password: "secret",
270+
LogLevel: "info",
271+
Username: "user",
272+
PasswordFilePath: "",
273+
BulkSize: -1, // disable bulk; we want immediate flush
274+
},
276275
expectedError: false,
277276
},
278277
{
279278
name: "success with valid configuration and error log level",
280279
config: &Configuration{
281-
Servers: []string{testServer.URL},
282-
AllowTokenFromContext: true,
283-
Password: "secret",
284-
LogLevel: "error",
285-
Username: "user",
286-
PasswordFilePath: "",
287-
BulkSize: -1, // disable bulk; we want immediate flush
288-
},
280+
Servers: []string{testServer.URL},
281+
AllowTokenFromContext: true,
282+
Password: "secret",
283+
LogLevel: "error",
284+
Username: "user",
285+
PasswordFilePath: "",
286+
BulkSize: -1, // disable bulk; we want immediate flush
287+
},
289288
expectedError: false,
290289
},
291290
}

0 commit comments

Comments
 (0)