package gosnitch

import "testing"

func TestPidof(t *testing.T) {
	_, err := Pidof("go")
	if err != nil {
		t.Error("Did not find pid of 'go'")
	}
}

func TestPidofNotExisting(t *testing.T) {
	pid, err := Pidof("fake-process")
	if err == nil {
		t.Errorf("Found pid %s when expected to find nothing", pid)
	}
}

func TestProbe(t *testing.T) {
	pid, err := Pidof("go")
	if err != nil {
		t.Error("Expected to find 'go' pid but found nothing")
	}

	s := NewTopSampler(pid)
	s.Probe(pid)
}

func TestProbeNotExistingDoesNotPanic(t *testing.T) {
	s := NewTopSampler(99999999999999999)
	s.Probe(99999999999999999)
}
package gosnitch

import "testing"

func TestPidof(t *testing.T) {
	_, err := Pidof("go")
	if err != nil {
		t.Error("Did not find pid of 'go'")
	}
}

func TestPidofNotExisting(t *testing.T) {
	pid, err := Pidof("fake-process")
	if err == nil {
		t.Errorf("Found pid %s when expected to find nothing", pid)
	}
}

func TestProbe(t *testing.T) {
	pid, err := Pidof("go")
	if err != nil {
		t.Error("Expected to find 'go' pid but found nothing")
	}

	s := NewTopSampler(pid)
	s.Probe(pid)
}
--- 
+++ 
@@ -25,3 +25,8 @@
 	s := NewTopSampler(pid)
 	s.Probe(pid)
 }
+
+func TestProbeNotExistingDoesNotPanic(t *testing.T) {
+	s := NewTopSampler(99999999999999999)
+	s.Probe(99999999999999999)
+}
Make sure that Probe called on unexisting pid does not crash
