test: fix TestDupNamespaces

add Root in created spec, or error message is 'Root must be specified'

Signed-off-by: Ace-Tang <aceapril@126.com>
This commit is contained in:
Ace-Tang 2018-11-06 11:34:33 +08:00
parent b1068fb925
commit 95d1aa1886
1 changed files with 5 additions and 1 deletions

View File

@ -4,6 +4,7 @@ package specconv
import (
"os"
"strings"
"testing"
"github.com/opencontainers/runc/libcontainer/configs"
@ -395,6 +396,9 @@ func TestSpecconvExampleValidate(t *testing.T) {
func TestDupNamespaces(t *testing.T) {
spec := &specs.Spec{
Root: &specs.Root{
Path: "rootfs",
},
Linux: &specs.Linux{
Namespaces: []specs.LinuxNamespace{
{
@ -412,7 +416,7 @@ func TestDupNamespaces(t *testing.T) {
Spec: spec,
})
if err == nil {
if !strings.Contains(err.Error(), "malformed spec file: duplicated ns") {
t.Errorf("Duplicated namespaces should be forbidden")
}
}