39 lines
767 B
Go
39 lines
767 B
Go
|
package integration
|
||
|
|
||
|
import (
|
||
|
"strings"
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func TestExecPS(t *testing.T) {
|
||
|
if testing.Short() {
|
||
|
return
|
||
|
}
|
||
|
|
||
|
rootfs, err := newRootFs()
|
||
|
if err != nil {
|
||
|
t.Fatal(err)
|
||
|
}
|
||
|
defer remove(rootfs)
|
||
|
|
||
|
config := newTemplateConfig(rootfs)
|
||
|
buffers, exitCode, err := runContainer(config, "", "ps")
|
||
|
if err != nil {
|
||
|
t.Fatal(err)
|
||
|
}
|
||
|
|
||
|
if exitCode != 0 {
|
||
|
t.Fatalf("exit code not 0. code %d stderr %q", exitCode, buffers.Stderr)
|
||
|
}
|
||
|
|
||
|
lines := strings.Split(buffers.Stdout.String(), "\n")
|
||
|
if len(lines) < 2 {
|
||
|
t.Fatalf("more than one process running for output %q", buffers.Stdout.String())
|
||
|
}
|
||
|
expected := `1 root ps`
|
||
|
actual := strings.Trim(lines[1], "\n ")
|
||
|
if actual != expected {
|
||
|
t.Fatalf("expected output %q but received %q", expected, actual)
|
||
|
}
|
||
|
}
|