gitlab.com/Raven-IO/raven-delve@v1.22.4/pkg/terminal/terminal_test.go (about)

     1  package terminal
     2  
     3  import (
     4  	"errors"
     5  	"net/rpc"
     6  	"testing"
     7  )
     8  
     9  func TestIsErrProcessExited(t *testing.T) {
    10  	tests := []struct {
    11  		name   string
    12  		err    error
    13  		result bool
    14  	}{
    15  		{"empty error", errors.New(""), false},
    16  		{"non-ServerError", errors.New("Process 33122 has exited with status 0"), false},
    17  		{"ServerError with zero status", rpc.ServerError("Process 33122 has exited with status 0"), true},
    18  		{"ServerError with non-zero status", rpc.ServerError("Process 2 has exited with status 25"), true},
    19  	}
    20  	for _, test := range tests {
    21  		if isErrProcessExited(test.err) != test.result {
    22  			t.Error(test.name)
    23  		}
    24  	}
    25  }