github.com/kata-containers/runtime@v0.0.0-20210505125100-04f29832a923/virtcontainers/nsenter_test.go (about) 1 // Copyright (c) 2016 Intel Corporation 2 // 3 // SPDX-License-Identifier: Apache-2.0 4 // 5 6 package virtcontainers 7 8 import ( 9 "strings" 10 "testing" 11 12 "github.com/stretchr/testify/assert" 13 ) 14 15 func testNsEnterFormatArgs(t *testing.T, args []string, expected string) { 16 nsenter := &nsenter{} 17 18 cmd, err := nsenter.formatArgs(args) 19 assert.NoError(t, err) 20 assert.Equal(t, strings.Join(cmd, " "), expected) 21 } 22 23 func TestNsEnterFormatArgsHello(t *testing.T) { 24 expectedCmd := "nsenter --target -1 --mount --uts --ipc --net --pid echo hello" 25 26 args := []string{"echo", "hello"} 27 28 testNsEnterFormatArgs(t, args, expectedCmd) 29 }