@@ -241,7 +241,7 @@ func TestInitConfig(t *testing.T) {
241
241
FilePath : filepath .Join (testFiles , "newConfig" ),
242
242
Reader : io .MultiReader (
243
243
strings .NewReader ("y\n " ),
244
- strings .NewReader ("https://ahost \n " ),
244
+ strings .NewReader ("1 \n " ),
245
245
strings .NewReader ("1\n " ),
246
246
strings .NewReader ("1\n " ),
247
247
strings .NewReader ("anapikey\n " ),
@@ -257,13 +257,14 @@ func TestInitConfig(t *testing.T) {
257
257
}},
258
258
wantSettings : map [string ]interface {}{
259
259
"apikey" : "somekey" ,
260
- "host" : "https://ahost " ,
260
+ "host" : "https://api.elastic-cloud.com " ,
261
261
"insecure" : true ,
262
262
"output" : "text" ,
263
263
},
264
- wantOutput : disclaimer + missingConfigMsg + hostMsg +
265
- formatChoiceMsg + "\n " + authChoiceMsg + "\n " + apiKeyMsg + "\n " +
266
- "\n " + fmt .Sprintf (validCredentialsMsg , "anacleto" ) + finalMsg + "\n " ,
264
+ wantOutput : disclaimer + missingConfigMsg + hostChoiceMsg + "\n " +
265
+ fmt .Sprintf (essChoiceMsg , essHostAddress ) + formatChoiceMsg +
266
+ "\n " + authChoiceMsg + "\n " + apiKeyMsg + "\n " + "\n " +
267
+ fmt .Sprintf (validCredentialsMsg , "anacleto" ) + finalMsg + "\n " ,
267
268
},
268
269
{
269
270
name : "doesn't find a config file and user creates a new one with user/pass" ,
@@ -272,6 +273,7 @@ func TestInitConfig(t *testing.T) {
272
273
FilePath : filepath .Join (testFiles , "newConfigUserPass" ),
273
274
Reader : io .MultiReader (
274
275
strings .NewReader ("y\n " ),
276
+ strings .NewReader ("2\n " ),
275
277
strings .NewReader ("https://ahost\n " ),
276
278
strings .NewReader ("1\n " ),
277
279
strings .NewReader ("2\n " ),
@@ -298,7 +300,7 @@ func TestInitConfig(t *testing.T) {
298
300
"pass" : "apassword" ,
299
301
"user" : "auser" ,
300
302
},
301
- wantOutput : disclaimer + missingConfigMsg + hostMsg +
303
+ wantOutput : disclaimer + missingConfigMsg + hostChoiceMsg + " \n " + eceHostMsg +
302
304
formatChoiceMsg + "\n " + authChoiceMsg + "\n " + userMsg + passMsg +
303
305
"\n " + "\n " + fmt .Sprintf (validCredentialsMsg , "auser" ) + finalMsg + "\n " ,
304
306
},
@@ -309,6 +311,7 @@ func TestInitConfig(t *testing.T) {
309
311
FilePath : filepath .Join (testFiles , "doesnt_matter" ),
310
312
Reader : io .MultiReader (
311
313
strings .NewReader ("y\n " ),
314
+ strings .NewReader ("3\n " ),
312
315
strings .NewReader ("https://ahost\n " ),
313
316
strings .NewReader ("1\n " ),
314
317
strings .NewReader ("1\n " ),
@@ -331,9 +334,9 @@ func TestInitConfig(t *testing.T) {
331
334
},
332
335
wantOutput : disclaimer +
333
336
fmt .Sprintf (settingsPathMsg , "test_files/userpassmodif.yaml" ) +
334
- userPassConfigToModifyContents + "\n " + existingConfigMsg + hostMsg +
335
- formatChoiceMsg + "\n " + authChoiceMsg + "\n " + apiKeyMsg + "\n " +
336
- "\n " + fmt .Sprintf (validCredentialsMsg , "anacleto" ) + finalMsg + "\n " ,
337
+ userPassConfigToModifyContents + "\n " + existingConfigMsg + hostChoiceMsg +
338
+ "\n " + esspHostMsg + formatChoiceMsg + "\n " + authChoiceMsg + "\n " + apiKeyMsg +
339
+ "\n " + " \n " + fmt .Sprintf (validCredentialsMsg , "anacleto" ) + finalMsg + "\n " ,
337
340
},
338
341
{
339
342
name : "finds a config file and user changes the values, from apikey to user/pass" ,
@@ -342,6 +345,7 @@ func TestInitConfig(t *testing.T) {
342
345
FilePath : filepath .Join (testFiles , "doesnt_matter" ),
343
346
Reader : io .MultiReader (
344
347
strings .NewReader ("y\n " ),
348
+ strings .NewReader ("2\n " ),
345
349
strings .NewReader ("https://ahost\n " ),
346
350
strings .NewReader ("1\n " ),
347
351
strings .NewReader ("2\n " ),
@@ -370,9 +374,9 @@ func TestInitConfig(t *testing.T) {
370
374
},
371
375
wantOutput : disclaimer +
372
376
fmt .Sprintf (settingsPathMsg , "test_files/apikeymodif.yaml" ) +
373
- apiKeyConfigToModifyContents + "\n " + existingConfigMsg + hostMsg +
374
- formatChoiceMsg + "\n " + authChoiceMsg + "\n " + userMsg + passMsg +
375
- "\n " + "\n " + fmt .Sprintf (validCredentialsMsg , "auser" ) + finalMsg + "\n " ,
377
+ apiKeyConfigToModifyContents + "\n " + existingConfigMsg + hostChoiceMsg +
378
+ " \n " + eceHostMsg + formatChoiceMsg + "\n " + authChoiceMsg + "\n " + userMsg +
379
+ passMsg + "\n " + "\n " + fmt .Sprintf (validCredentialsMsg , "auser" ) + finalMsg + "\n " ,
376
380
},
377
381
}
378
382
for _ , tt := range tests {
0 commit comments