mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-27 17:21:34 +00:00
31 lines
638 B
Go
31 lines
638 B
Go
package procspy
|
|
|
|
import (
|
|
"github.com/weaveworks/scope/probe/process"
|
|
)
|
|
|
|
// SetFixtures declares constant Connection and ConnectionProcs which will
|
|
// always be returned by the package-level Connections and Processes
|
|
// functions. It's designed to be used in tests.
|
|
|
|
type fixedConnIter []Connection
|
|
|
|
func (f *fixedConnIter) Next() *Connection {
|
|
if len(*f) == 0 {
|
|
return nil
|
|
}
|
|
|
|
car := (*f)[0]
|
|
*f = (*f)[1:]
|
|
|
|
return &car
|
|
}
|
|
|
|
// SetFixtures is used in test scenarios to have known output.
|
|
func SetFixtures(c []Connection) {
|
|
cbConnections = func(bool, process.Walker) (ConnIter, error) {
|
|
f := fixedConnIter(c)
|
|
return &f, nil
|
|
}
|
|
}
|