Merge pull request #2787 from rajdeepd/master

Added two test cases for KubeletClient
This commit is contained in:
Brendan Burns 2014-12-09 15:19:01 -08:00
commit e8280364fc

View File

@ -18,6 +18,7 @@ package client
import ( import (
"encoding/json" "encoding/json"
"fmt"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"net/url" "net/url"
@ -109,3 +110,27 @@ func TestHTTPKubeletClientNotFound(t *testing.T) {
t.Errorf("Expected %#v, Got %#v", ErrPodInfoNotAvailable, err) t.Errorf("Expected %#v, Got %#v", ErrPodInfoNotAvailable, err)
} }
} }
func TestNewKubeletClient(t *testing.T) {
config := &KubeletConfig{
Port: 9000,
EnableHttps: false,
}
client, err := NewKubeletClient(config)
if err != nil {
t.Errorf("Error %#v while trying to create a client.", err)
}
if client == nil {
t.Errorf("%#v client is nil.", client)
}
host := "127.0.0.1"
healthStatus, err := client.HealthCheck(host)
if !(fmt.Sprintf("%v", healthStatus) == "unknown") {
t.Errorf("Expected %v and got %v.", "unknown", healthStatus)
}
if err == nil {
t.Errorf("%#v", "Expected a non nil error")
}
}