@@ -25,6 +25,7 @@ import (
2525 "io/ioutil"
2626 "log"
2727 "os"
28+ "path/filepath"
2829 "reflect"
2930 "runtime"
3031 "strings"
@@ -601,3 +602,59 @@ func getShmSize(opts []string) string {
601602 }
602603 return ""
603604}
605+
606+ func TestWithoutMounts (t * testing.T ) {
607+ t .Parallel ()
608+ var s Spec
609+
610+ x := func (s string ) string {
611+ if runtime .GOOS == "windows" {
612+ return filepath .Join ("C:\\ " , filepath .Clean (s ))
613+ }
614+ return s
615+ }
616+ opts := []SpecOpts {
617+ WithMounts ([]specs.Mount {
618+ {
619+ Destination : x ("/dst1" ),
620+ Source : x ("/src1" ),
621+ },
622+ {
623+ Destination : x ("/dst2" ),
624+ Source : x ("/src2" ),
625+ },
626+ {
627+ Destination : x ("/dst3" ),
628+ Source : x ("/src3" ),
629+ },
630+ }),
631+ WithoutMounts (x ("/dst2" ), x ("/dst3" )),
632+ WithMounts ([]specs.Mount {
633+ {
634+ Destination : x ("/dst4" ),
635+ Source : x ("/src4" ),
636+ },
637+ }),
638+ }
639+
640+ expected := []specs.Mount {
641+ {
642+ Destination : x ("/dst1" ),
643+ Source : x ("/src1" ),
644+ },
645+ {
646+ Destination : x ("/dst4" ),
647+ Source : x ("/src4" ),
648+ },
649+ }
650+
651+ for _ , opt := range opts {
652+ if err := opt (nil , nil , nil , & s ); err != nil {
653+ t .Fatal (err )
654+ }
655+ }
656+
657+ if ! reflect .DeepEqual (expected , s .Mounts ) {
658+ t .Fatalf ("expected %+v, got %+v" , expected , s .Mounts )
659+ }
660+ }
0 commit comments