github.com/keysonzzz/kmg@v0.0.0-20151121023212-05317bfd7d39/kmgProcess/process_test.go (about) 1 package kmgProcess 2 3 import ( 4 "github.com/bronze1man/kmg/kmgTest" 5 "testing" 6 ) 7 8 func TestExtractProcessList(t *testing.T) { 9 pList := Extract(` 5393 /usr/bin/InlProxy vpnAccount -redisAddr=127.0.0.1:30001 10 5424 /usr/bin/xasdf -block 11 5455 /usr/bin/asdfkja;sdflk -nl asdfadsf;ak 12 5590 /usr/bin/abc 13 6625 InlProxy 14 7254 InlProxy abc 15 27939 /usr/bin/InlProxy`) 16 kmgTest.Equal(len(pList), 7) 17 kmgTest.Equal(pList[1].Id, 5424) 18 kmgTest.Equal(pList[5].Command, "InlProxy abc") 19 } 20 21 func TestDiff(t *testing.T) { 22 notExpect, notRunning := Diff([]*Process{ 23 {Command: "a"}, 24 {Command: "b"}, 25 {Command: "a"}, 26 {Command: "c"}, 27 }, []*Process{ 28 {Command: "a"}, 29 {Command: "a"}, 30 {Command: "c"}, 31 {Command: "e"}, 32 {Command: "e"}, 33 }) 34 kmgTest.Equal(len(notExpect), 2) 35 kmgTest.Equal(notExpect[0].Command, "e") 36 kmgTest.Equal(notExpect[1].Command, "e") 37 kmgTest.Equal(len(notRunning), 1) 38 kmgTest.Equal(notRunning[0].Command, "b") 39 }