Fix tests.
parent
5b5442be11
commit
2486a8b612
|
@ -73,8 +73,7 @@ func (*rpcClientFactory) NewClient(storePath, certsDir string) libmachine.API {
|
|||
return c
|
||||
}
|
||||
|
||||
// Gets a new client depending on the clientType specified
|
||||
// defaults to the libmachine client
|
||||
// NewAPIClient gets a new client.
|
||||
func NewAPIClient() (libmachine.API, error) {
|
||||
storePath := constants.GetMinipath()
|
||||
certsDir := constants.MakeMiniPath("certs")
|
||||
|
|
|
@ -116,8 +116,7 @@ func TestGetDriver(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestLocalClientNewHost(t *testing.T) {
|
||||
f := clientFactories[ClientTypeLocal]
|
||||
c := f.NewClient("", "")
|
||||
c := (&localClientFactory{}).NewClient("", "")
|
||||
|
||||
var tests = []struct {
|
||||
description string
|
||||
|
@ -162,42 +161,6 @@ func TestLocalClientNewHost(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestNewAPIClient(t *testing.T) {
|
||||
var tests = []struct {
|
||||
description string
|
||||
clientType ClientType
|
||||
err bool
|
||||
}{
|
||||
{
|
||||
description: "Client type local",
|
||||
clientType: ClientTypeLocal,
|
||||
},
|
||||
{
|
||||
description: "Client type RPC",
|
||||
clientType: ClientTypeRPC,
|
||||
},
|
||||
{
|
||||
description: "Incorrect client type",
|
||||
clientType: -1,
|
||||
err: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
test := test
|
||||
t.Run(test.description, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := NewAPIClient(test.clientType)
|
||||
if err != nil && !test.err {
|
||||
t.Errorf("Unexpected error: %s", err)
|
||||
}
|
||||
if err == nil && test.err {
|
||||
t.Errorf("No error returned, but expected err")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func makeTempDir() string {
|
||||
tempDir, err := ioutil.TempDir("", "minipath")
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue