Don't panic tests on Darwin.

Use the proper DialStub in the container setup.

Also, one change to increase test coverage.
This commit is contained in:
Peter Bourgon
2015-07-30 15:16:26 +02:00
parent a565acc871
commit 70f8c62415
3 changed files with 16 additions and 1 deletions
+1 -1
View File
@@ -122,7 +122,7 @@ func (c *container) StartGatheringStats() error {
return
}
dial, err := net.Dial(url.Scheme, url.Path)
dial, err := DialStub(url.Scheme, url.Path)
if err != nil {
log.Printf("docker container: %v", err)
return
+4
View File
@@ -4,6 +4,8 @@ import (
"bufio"
"encoding/json"
"io"
"io/ioutil"
"log"
"net"
"net/http"
"runtime"
@@ -31,6 +33,8 @@ func (c *mockConnection) Close() error {
}
func TestContainer(t *testing.T) {
log.SetOutput(ioutil.Discard)
oldDialStub, oldNewClientConnStub := docker.DialStub, docker.NewClientConnStub
defer func() { docker.DialStub, docker.NewClientConnStub = oldDialStub, oldNewClientConnStub }()
+11
View File
@@ -8,6 +8,17 @@ import (
"github.com/weaveworks/scope/test"
)
func TestBasicWalk(t *testing.T) {
// Don't panic or error.
var (
procRoot = "/proc"
procFunc = func(process.Process) {}
)
if err := process.NewWalker(procRoot).Walk(procFunc); err != nil {
t.Fatal(err)
}
}
func TestCache(t *testing.T) {
processes := []process.Process{
{PID: 1, PPID: 0, Comm: "init"},