2016-10-25 17:01:38 +00:00
|
|
|
package terminal
|
|
|
|
|
|
|
|
import (
|
2019-07-17 22:54:15 +00:00
|
|
|
"errors"
|
|
|
|
"net/rpc"
|
2016-11-15 16:16:33 +00:00
|
|
|
"testing"
|
2016-10-25 17:01:38 +00:00
|
|
|
)
|
|
|
|
|
2019-07-17 22:54:15 +00:00
|
|
|
func TestIsErrProcessExited(t *testing.T) {
|
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
err error
|
|
|
|
result bool
|
|
|
|
}{
|
|
|
|
{"empty error", errors.New(""), false},
|
|
|
|
{"non-ServerError", errors.New("Process 33122 has exited with status 0"), false},
|
|
|
|
{"ServerError with zero status", rpc.ServerError("Process 33122 has exited with status 0"), true},
|
|
|
|
{"ServerError with non-zero status", rpc.ServerError("Process 2 has exited with status 25"), true},
|
|
|
|
}
|
|
|
|
for _, test := range tests {
|
|
|
|
if isErrProcessExited(test.err) != test.result {
|
|
|
|
t.Error(test.name)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|