package main

import (
	"testing"
)

func TestProcList_NonEmpty(t *testing.T) {
	cap := &Capability{Name: "proc.list"}
	res, code, err := runProcList(cap, map[string]any{})
	if err != nil {
		t.Fatalf("proc.list: %v", err)
	}
	if code != 0 {
		t.Fatalf("expected code=0 got %d", code)
	}
	m := res.(map[string]any)
	procs := m["processes"].([]map[string]any)
	if len(procs) == 0 {
		t.Fatalf("expected processes > 0")
	}
	for _, p := range procs {
		if p["pid"].(int) <= 0 {
			t.Fatalf("invalid pid: %v", p)
		}
	}
}
