Remove extra test flags from all commands

Currently all commands are being build with extra flags. The extra
flags appear because of a direct import of the testing package from
the fake_etcd_client.go source file.

Remove the direct import of the testing package. Add a tools.T
interface to support existing behavior. Also clean up two TODO items
by remove using of the expectError and expectNoError functions.

Fixes #579
This commit is contained in:
Kelsey Hightower
2014-07-27 06:30:32 -07:00
parent 8a5cc87df8
commit 87fa19cdfe
5 changed files with 68 additions and 38 deletions

View File

@@ -18,7 +18,6 @@ package tools
import (
"fmt"
"testing"
"github.com/coreos/go-etcd/etcd"
)
@@ -28,13 +27,19 @@ type EtcdResponseWithError struct {
E error
}
// TestLogger is a type passed to Test functions to support formatted test logs.
type TestLogger interface {
Errorf(format string, args ...interface{})
Logf(format string, args ...interface{})
}
type FakeEtcdClient struct {
watchCompletedChan chan bool
Data map[string]EtcdResponseWithError
DeletedKeys []string
Err error
t *testing.T
t TestLogger
Ix int
// Will become valid after Watch is called; tester may write to it. Tester may
@@ -45,7 +50,7 @@ type FakeEtcdClient struct {
WatchStop chan<- bool
}
func MakeFakeEtcdClient(t *testing.T) *FakeEtcdClient {
func MakeFakeEtcdClient(t TestLogger) *FakeEtcdClient {
ret := &FakeEtcdClient{
t: t,
Data: map[string]EtcdResponseWithError{},