package service import "testing" func TestRunHandleCloseIsIdempotent(t *testing.T) { calls := 0 handle := &RunHandle{ close: func() { calls++ }, } handle.Close() handle.Close() if calls != 1 { t.Fatalf("close called %d times, want 1", calls) } }