Added test case for ServerAPIVersions

pull/6/head
Rajdeep Dua 2014-12-02 21:55:44 -08:00
parent ffcbe2fa10
commit e47e1ee025
1 changed files with 23 additions and 0 deletions

View File

@ -578,6 +578,29 @@ func TestGetServerVersion(t *testing.T) {
}
}
func TestGetServerAPIVersions(t *testing.T) {
versions := []string{"v1", "v2", "v3"}
expect := api.APIVersions{Versions: versions}
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
output, err := json.Marshal(expect)
if err != nil {
t.Errorf("unexpected encoding error: %v", err)
return
}
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
w.Write(output)
}))
client := NewOrDie(&Config{Host: server.URL})
got, err := client.ServerAPIVersions()
if err != nil {
t.Fatalf("unexpected encoding error: %v", err)
}
if e, a := expect, *got; !reflect.DeepEqual(e, a) {
t.Errorf("expected %v, got %v", e, a)
}
}
func TestListMinions(t *testing.T) {
c := &testClient{
Request: testRequest{Method: "GET", Path: "/minions"},