Skip to content

Commit 6b16d3c

Browse files
author
zhuyiqing.wiz
committed
unittest for edit mount order
Signed-off-by: zhuyiqing.wiz <[email protected]>
1 parent 7d4fb44 commit 6b16d3c

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

pkg/cdi/container-edits_test.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,45 @@ func TestApplyContainerEdits(t *testing.T) {
638638
},
639639
},
640640
},
641+
{
642+
name: "mount added by edit comes after existing ones of same number of path parts",
643+
spec: &oci.Spec{
644+
Mounts: []oci.Mount{
645+
{
646+
Source: "/some/host/path1",
647+
Destination: "/dest/path/c",
648+
},
649+
{
650+
Source: "/some/host/path2",
651+
Destination: "/dest/path/b",
652+
},
653+
},
654+
},
655+
edits: &cdi.ContainerEdits{
656+
Mounts: []*cdi.Mount{
657+
{
658+
HostPath: "/some/host/path3",
659+
ContainerPath: "/dest/path/a",
660+
},
661+
},
662+
},
663+
result: &oci.Spec{
664+
Mounts: []oci.Mount{
665+
{
666+
Source: "/some/host/path1",
667+
Destination: "/dest/path/c",
668+
},
669+
{
670+
Source: "/some/host/path2",
671+
Destination: "/dest/path/b",
672+
},
673+
{
674+
Source: "/some/host/path3",
675+
Destination: "/dest/path/a",
676+
},
677+
},
678+
},
679+
},
641680
} {
642681
t.Run(tc.name, func(t *testing.T) {
643682
edits := ContainerEdits{tc.edits}

0 commit comments

Comments
 (0)