@@ -676,13 +676,13 @@ func TestParseMountinfoExtraCases(t *testing.T) {
676676 name : "one optional field" ,
677677 entry : `251 15 0:3573 / /mnt/point rw,relatime shared:123 - aufs none rw` ,
678678 valid : true ,
679- exp : & Info {Mountpoint : "/mnt/point" , FSType : "aufs" , Source : "none" , Optional : "shared:123 extra:tag what:ever " },
679+ exp : & Info {Mountpoint : "/mnt/point" , FSType : "aufs" , Source : "none" , Optional : "shared:123" },
680680 },
681681 {
682682 name : "extra optional fields" , // which we carefully gather
683683 entry : `251 15 0:3573 / /mnt/point rw,relatime shared:123 extra:tag what:ever key:value - aufs none rw` ,
684684 valid : true ,
685- exp : & Info {Mountpoint : "/mnt/point" , FSType : "aufs" , Source : "none" , Optional : "shared:123 extra:tag what:ever" },
685+ exp : & Info {Mountpoint : "/mnt/point" , FSType : "aufs" , Source : "none" , Optional : "shared:123 extra:tag what:ever key:value " },
686686 },
687687 {
688688 name : "empty source field (kernel < 5.1 bug)" ,
@@ -693,34 +693,40 @@ func TestParseMountinfoExtraCases(t *testing.T) {
693693 }
694694
695695 for _ , tc := range testcases {
696- r := bytes .NewBufferString (tc .entry )
697- info , err := GetMountsFromReader (r , nil )
698- if ! tc .valid {
699- if err == nil {
700- t .Errorf ("case %q: expected error, got nil" , tc .name )
696+ tc := tc
697+ t .Run (tc .name , func (t * testing.T ) {
698+ r := bytes .NewBufferString (tc .entry )
699+ info , err := GetMountsFromReader (r , nil )
700+ if ! tc .valid {
701+ if err == nil {
702+ t .Errorf ("expected error, got nil" )
703+ }
704+ return
701705 }
702- continue
703- }
704- if err != nil {
705- t .Errorf ("case %q: expected no error, got %v" , tc .name , err )
706- continue
707- }
708- if len (info ) != 1 {
709- t .Errorf ("case %q: expected 1 result, got %d" , tc .name , len (info ))
710- }
711- if tc .exp == nil {
712- continue
713- }
714- i := info [0 ]
715- if tc .exp .Mountpoint != "" && tc .exp .Mountpoint != i .Mountpoint {
716- t .Errorf ("case %q: expected mp %s, got %s" , tc .name , tc .exp .Mountpoint , i .Mountpoint )
717- }
718- if tc .exp .FSType != "" && tc .exp .FSType != i .FSType {
719- t .Errorf ("case %q: expected fs %s, got %s" , tc .name , tc .exp .FSType , i .FSType )
720- }
721- if tc .exp .Source != "" && tc .exp .Source != i .Source {
722- t .Errorf ("case %q: expected src %s, got %s" , tc .name , tc .exp .Source , i .Source )
723- }
706+ if err != nil {
707+ t .Errorf ("expected no error, got %v" , err )
708+ return
709+ }
710+ if len (info ) != 1 {
711+ t .Errorf ("expected 1 result, got %d" , len (info ))
712+ }
713+ if tc .exp == nil {
714+ return
715+ }
716+ i := info [0 ]
717+ if tc .exp .Mountpoint != "" && tc .exp .Mountpoint != i .Mountpoint {
718+ t .Errorf ("expected mp %s, got %s" , tc .exp .Mountpoint , i .Mountpoint )
719+ }
720+ if tc .exp .FSType != "" && tc .exp .FSType != i .FSType {
721+ t .Errorf ("expected fs %s, got %s" , tc .exp .FSType , i .FSType )
722+ }
723+ if tc .exp .Source != "" && tc .exp .Source != i .Source {
724+ t .Errorf ("expected src %s, got %s" , tc .exp .Source , i .Source )
725+ }
726+ if tc .exp .Optional != "" && tc .exp .Optional != i .Optional {
727+ t .Errorf ("expected optional %s, got %s" , tc .exp .Optional , i .Optional )
728+ }
729+ })
724730 }
725731}
726732
0 commit comments