This repository has been archived on 2015-04-29. You can view files and clone it, but cannot push or open issues or pull requests.
jsh/df/main_test.go
Ian Adam Naval e2ed6a4111 Add df
2014-10-14 16:32:08 -04:00

23 lines
752 B
Go

package main
import (
"jsh"
"reflect"
"testing"
)
func TestPsOutputToProcesses(t *testing.T) {
psOutput := `USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.1 26204 4916 ? Ss 00:39 0:00 /sbin/init
root 2 0.0 0.0 0 0 ? S 00:39 0:00 [kthreadd]`
processes := PsOutputToProcesses(psOutput)
expected := []jsh.Process{jsh.Process{"root", "1", "0.0", "0.1", "26204",
"4916", "?", "Ss", "00:39", "0:00", "/sbin/init"},
jsh.Process{"root", "2", "0.0", "0.0", "0", "0", "?", "S", "00:39",
"0:00", "[kthreadd]"}}
actual := *processes
if !reflect.DeepEqual(expected, actual) {
t.Errorf("Processes not parsed correctly.\n%s != %s", expected, actual)
}
}