@@ -494,68 +494,79 @@ func validateLogsCmd(ctx context.Context, t *testing.T, profile string) {
494
494
495
495
// validateProfileCmd asserts "profile" command functionality
496
496
func validateProfileCmd (ctx context.Context , t * testing.T , profile string ) {
497
- // Profile command should not create a nonexistent profile
498
- nonexistentProfile := "lis"
499
- rr , err := Run (t , exec .CommandContext (ctx , Target (), "profile" , nonexistentProfile ))
500
- rr , err = Run (t , exec .CommandContext (ctx , Target (), "profile" , "list" , "--output" , "json" ))
501
- if err != nil {
502
- t .Errorf ("%s failed: %v" , rr .Args , err )
503
- }
504
- var profileJson map [string ][]map [string ]interface {}
505
- err = json .Unmarshal (rr .Stdout .Bytes (), & profileJson )
506
- if err != nil {
507
- t .Errorf ("%s failed: %v" , rr .Args , err )
508
- }
509
- for profileK := range profileJson {
510
- for _ , p := range profileJson [profileK ] {
511
- var name = p ["Name" ]
512
- if (name == nonexistentProfile ) {
513
- t .Errorf ("minikube profile %s should not exist" , nonexistentProfile )
497
+ t .Run ("profile_not_create" , func (t * testing.T ) {
498
+ // Profile command should not create a nonexistent profile
499
+ nonexistentProfile := "lis"
500
+ rr , err := Run (t , exec .CommandContext (ctx , Target (), "profile" , nonexistentProfile ))
501
+ if err != nil {
502
+ t .Errorf ("%s failed: %v" , rr .Args , err )
503
+ }
504
+ rr , err = Run (t , exec .CommandContext (ctx , Target (), "profile" , "list" , "--output" , "json" ))
505
+ if err != nil {
506
+ t .Errorf ("%s failed: %v" , rr .Args , err )
507
+ }
508
+ var profileJSON map [string ][]map [string ]interface {}
509
+ err = json .Unmarshal (rr .Stdout .Bytes (), & profileJSON )
510
+ if err != nil {
511
+ t .Errorf ("%s failed: %v" , rr .Args , err )
512
+ }
513
+ for profileK := range profileJSON {
514
+ for _ , p := range profileJSON [profileK ] {
515
+ var name = p ["Name" ]
516
+ if name == nonexistentProfile {
517
+ t .Errorf ("minikube profile %s should not exist" , nonexistentProfile )
518
+ }
514
519
}
515
520
}
516
- }
521
+ })
517
522
518
- // List profiles
519
- rr , err = Run (t , exec .CommandContext (ctx , Target (), "profile" , "list" ))
520
- if err != nil {
521
- t .Errorf ("%s failed: %v" , rr .Args , err )
522
- }
523
+ t .Run ("profile_list" , func (t * testing.T ) {
524
+ // List profiles
525
+ rr , err := Run (t , exec .CommandContext (ctx , Target (), "profile" , "list" ))
526
+ if err != nil {
527
+ t .Errorf ("%s failed: %v" , rr .Args , err )
528
+ }
523
529
524
- // Table output
525
- listLines := strings .Split (strings .TrimSpace (rr .Stdout .String ()), "\n " )
526
- profileExists := false
527
- for i := 3 ; i < (len (listLines ) - 1 ); i ++ {
528
- profileLine := listLines [i ]
529
- if strings .Contains (profileLine , profile ) {
530
- profileExists = true
531
- break
530
+ // Table output
531
+ listLines := strings .Split (strings .TrimSpace (rr .Stdout .String ()), "\n " )
532
+ profileExists := false
533
+ for i := 3 ; i < (len (listLines ) - 1 ); i ++ {
534
+ profileLine := listLines [i ]
535
+ if strings .Contains (profileLine , profile ) {
536
+ profileExists = true
537
+ break
538
+ }
539
+ }
540
+ if ! profileExists {
541
+ t .Errorf ("%s failed: Missing profile '%s'. Got '\n %s\n '" , rr .Args , profile , rr .Stdout .String ())
532
542
}
533
- }
534
- if ! profileExists {
535
- t .Errorf ("%s failed: Missing profile '%s'. Got '\n %s\n '" , rr .Args , profile , rr .Stdout .String ())
536
- }
537
543
538
- // Json output
539
- rr , err = Run (t , exec .CommandContext (ctx , Target (), "profile" , "list" , "--output" , "json" ))
540
- if err != nil {
541
- t .Errorf ("%s failed: %v" , rr .Args , err )
542
- }
543
- var jsonObject map [string ][]map [string ]interface {}
544
- err = json .Unmarshal (rr .Stdout .Bytes (), & jsonObject )
545
- if err != nil {
546
- t .Errorf ("%s failed: %v" , rr .Args , err )
547
- }
548
- validProfiles := jsonObject ["valid" ]
549
- profileExists = false
550
- for _ , profileObject := range validProfiles {
551
- if profileObject ["Name" ] == profile {
552
- profileExists = true
553
- break
544
+ })
545
+
546
+ t .Run ("profile_json_output" , func (t * testing.T ) {
547
+ // Json output
548
+ rr , err := Run (t , exec .CommandContext (ctx , Target (), "profile" , "list" , "--output" , "json" ))
549
+ if err != nil {
550
+ t .Errorf ("%s failed: %v" , rr .Args , err )
554
551
}
555
- }
556
- if ! profileExists {
557
- t .Errorf ("%s failed: Missing profile '%s'. Got '\n %s\n '" , rr .Args , profile , rr .Stdout .String ())
558
- }
552
+ var jsonObject map [string ][]map [string ]interface {}
553
+ err = json .Unmarshal (rr .Stdout .Bytes (), & jsonObject )
554
+ if err != nil {
555
+ t .Errorf ("%s failed: %v" , rr .Args , err )
556
+ }
557
+ validProfiles := jsonObject ["valid" ]
558
+ profileExists := false
559
+ for _ , profileObject := range validProfiles {
560
+ if profileObject ["Name" ] == profile {
561
+ profileExists = true
562
+ break
563
+ }
564
+ }
565
+ if ! profileExists {
566
+ t .Errorf ("%s failed: Missing profile '%s'. Got '\n %s\n '" , rr .Args , profile , rr .Stdout .String ())
567
+ }
568
+
569
+ })
559
570
}
560
571
561
572
// validateServiceCmd asserts basic "service" command functionality
0 commit comments