mirror of
https://github.com/kubereboot/kured.git
synced 2026-08-21 12:26:40 +00:00
Without this, it makes the code a bit harder to read. This fixes it by extracting the method. Signed-off-by: Jean-Philippe Evrard <open-source@a.spamming.party>
32 lines
655 B
Go
32 lines
655 B
Go
package util
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
)
|
|
|
|
func Test_buildHostCommand(t *testing.T) {
|
|
type args struct {
|
|
pid int
|
|
command []string
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
args args
|
|
want []string
|
|
}{
|
|
{
|
|
name: "Ensure command will run with nsenter",
|
|
args: args{pid: 1, command: []string{"ls", "-Fal"}},
|
|
want: []string{"/usr/bin/nsenter", "-m/proc/1/ns/mnt", "--", "ls", "-Fal"},
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if got := PrivilegedHostCommand(tt.args.pid, tt.args.command); !reflect.DeepEqual(got, tt.want) {
|
|
t.Errorf("buildHostCommand() = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|