mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
daemon/volume/mounts: Fix tests on Windows
The test was failing on Windows because it used Unix-style paths and relied on platform-specific filesystem behavior. Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
@@ -2,7 +2,7 @@ package mounts
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"path/filepath"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@@ -273,9 +273,12 @@ func TestLinuxValidateMounts(t *testing.T) {
|
|||||||
mount mount.Mount
|
mount mount.Mount
|
||||||
expected *MountPoint
|
expected *MountPoint
|
||||||
expErr string
|
expErr string
|
||||||
|
skipWindows bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
doc: "read-write",
|
doc: "read-write",
|
||||||
|
// Skip Windows tests because the source path won't be a valid Windows path.
|
||||||
|
skipWindows: true,
|
||||||
mount: mount.Mount{
|
mount: mount.Mount{
|
||||||
Source: tmpDir,
|
Source: tmpDir,
|
||||||
Target: "/tmp1",
|
Target: "/tmp1",
|
||||||
@@ -315,11 +318,11 @@ func TestLinuxValidateMounts(t *testing.T) {
|
|||||||
{
|
{
|
||||||
doc: "invalid source path",
|
doc: "invalid source path",
|
||||||
mount: mount.Mount{
|
mount: mount.Mount{
|
||||||
Source: filepath.Join(tmpDir, "no-such-path"),
|
Source: "/tmp/definitely-no-such-path",
|
||||||
Target: "/data/anonymous-read-only-volume",
|
Target: "/data/anonymous-read-only-volume",
|
||||||
Type: mount.TypeBind,
|
Type: mount.TypeBind,
|
||||||
},
|
},
|
||||||
expErr: `invalid mount config for type "bind": bind source path does not exist: ` + filepath.Join(tmpDir, "no-such-path"),
|
expErr: `invalid mount config for type "bind": bind source path does not exist: /tmp/definitely-no-such-path`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
doc: "invalid mount type",
|
doc: "invalid mount type",
|
||||||
@@ -335,6 +338,9 @@ func TestLinuxValidateMounts(t *testing.T) {
|
|||||||
|
|
||||||
for _, tc := range tests {
|
for _, tc := range tests {
|
||||||
t.Run(tc.doc, func(t *testing.T) {
|
t.Run(tc.doc, func(t *testing.T) {
|
||||||
|
if tc.skipWindows && runtime.GOOS == "windows" {
|
||||||
|
t.Skip("skip on Windows")
|
||||||
|
}
|
||||||
m, err := parser.ParseMountSpec(tc.mount)
|
m, err := parser.ParseMountSpec(tc.mount)
|
||||||
if tc.expErr != "" {
|
if tc.expErr != "" {
|
||||||
assert.Check(t, is.Nil(m))
|
assert.Check(t, is.Nil(m))
|
||||||
|
|||||||
Reference in New Issue
Block a user