mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 15:05:27 +00:00
Added test case for ServerAPIVersions
This commit is contained in:
parent
ffcbe2fa10
commit
e47e1ee025
@ -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) {
|
func TestListMinions(t *testing.T) {
|
||||||
c := &testClient{
|
c := &testClient{
|
||||||
Request: testRequest{Method: "GET", Path: "/minions"},
|
Request: testRequest{Method: "GET", Path: "/minions"},
|
||||||
|
Loading…
Reference in New Issue
Block a user