-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: mounting issue with single character volume on windows
Signed-off-by: axel7083 <[email protected]>
- Loading branch information
Showing
4 changed files
with
178 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package specgen | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestSplitVolumeString(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
volume string | ||
expect []string | ||
}{ | ||
// relative host paths | ||
{ | ||
name: "relative host path", | ||
volume: "./hello:/container", | ||
expect: []string{"./hello", "/container"}, | ||
}, | ||
{ | ||
name: "relative host path with options", | ||
volume: "./hello:/container:ro", | ||
expect: []string{"./hello", "/container", "ro"}, | ||
}, | ||
// absolute host path | ||
{ | ||
name: "absolute host path", | ||
volume: "/hello:/container", | ||
expect: []string{"/hello", "/container"}, | ||
}, | ||
{ | ||
name: "absolute host path with option", | ||
volume: "/hello:/container:ro", | ||
expect: []string{"/hello", "/container", "ro"}, | ||
}, | ||
{ | ||
name: "absolute host path with option", | ||
volume: "/hello:/container:ro", | ||
expect: []string{"/hello", "/container", "ro"}, | ||
}, | ||
// volume source | ||
{ | ||
name: "volume without option", | ||
volume: "vol-name:/container", | ||
expect: []string{"vol-name", "/container"}, | ||
}, | ||
{ | ||
name: "volume with option", | ||
volume: "vol-name:/container:ro", | ||
expect: []string{"vol-name", "/container", "ro"}, | ||
}, | ||
{ | ||
name: "single letter volume without option", | ||
volume: "a:/container", | ||
expect: []string{"a", "/container"}, | ||
}, | ||
{ | ||
name: "single letter volume with option", | ||
volume: "a:/container:ro", | ||
expect: []string{"a", "/container", "ro"}, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
parts := SplitVolumeString(tt.volume) | ||
|
||
assert.Equal(t, tt.expect, parts, tt.name) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package specgen | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestSplitVolumeString(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
volume string | ||
expect []string | ||
}{ | ||
// relative host paths | ||
{ | ||
name: "relative host path", | ||
volume: "./hello:/container", | ||
expect: []string{"./hello", "/container"}, | ||
}, | ||
{ | ||
name: "relative host path with options", | ||
volume: "./hello:/container:ro", | ||
expect: []string{"./hello", "/container", "ro"}, | ||
}, | ||
// absolute host path | ||
{ | ||
name: "absolute host path", | ||
volume: "C:\\hello:/container", | ||
expect: []string{"C:\\hello", "/container"}, | ||
}, | ||
{ | ||
name: "absolute host path with option", | ||
volume: "C:\\hello:/container:ro", | ||
expect: []string{"C:\\hello", "/container", "ro"}, | ||
}, | ||
{ | ||
name: "absolute host path with option", | ||
volume: "C:\\hello:/container:ro", | ||
expect: []string{"C:\\hello", "/container", "ro"}, | ||
}, | ||
{ | ||
name: "absolute extended host path", | ||
volume: `\\?\C:\hello:/container`, | ||
expect: []string{`\\?\C:\hello`, "/container"}, | ||
}, | ||
// volume source | ||
{ | ||
name: "volume without option", | ||
volume: "vol-name:/container", | ||
expect: []string{"vol-name", "/container"}, | ||
}, | ||
{ | ||
name: "volume with option", | ||
volume: "vol-name:/container:ro", | ||
expect: []string{"vol-name", "/container", "ro"}, | ||
}, | ||
{ | ||
name: "single letter volume without option", | ||
volume: "a:/container", | ||
expect: []string{"a", "/container"}, | ||
}, | ||
{ | ||
name: "single letter volume with option", | ||
volume: "a:/container:ro", | ||
expect: []string{"a", "/container", "ro"}, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
parts := SplitVolumeString(tt.volume) | ||
|
||
assert.Equal(t, tt.expect, parts, tt.name) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters