Improve test coverage.

This commit is contained in:
Nuno Cruces 2022-07-12 00:27:29 +01:00
parent 3274dd7bdb
commit ab2a08c75a

View file

@ -0,0 +1,31 @@
//go:build !windows && !darwin
package zencmd
import (
"os"
"testing"
)
func Test_getPidToPpidMap(t *testing.T) {
got, err := getPidToPpidMap()
if err != nil {
t.Fatalf("getPidToPpidMap() error = %v", err)
}
if ppid := got[os.Getpid()]; ppid != os.Getppid() {
t.Errorf("getPidToPpidMap()[%d] = %d; want %d", os.Getpid(), ppid, os.Getppid())
}
}
func Test_getPidToWindowMap(t *testing.T) {
got, err := getPidToWindowMap()
if err != nil {
if os.Getenv("DISPLAY") == "" {
t.Skip("skipping:", err)
}
t.Fatalf("getPidToWindowMap() error = %v", err)
}
if len(got) == 0 {
t.Errorf("getPidToWindowMap() %v", got)
}
}