mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
![Hu Keping](/assets/img/avatar_default.png)
Two main things - Create a real struct Info for all of the data with the proper types - Add test for REST API get info Signed-off-by: Hu Keping <hukeping@huawei.com>
38 lines
740 B
Go
38 lines
740 B
Go
package main
|
|
|
|
import (
|
|
"net/http"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestInfoApi(t *testing.T) {
|
|
endpoint := "/info"
|
|
|
|
statusCode, body, err := sockRequest("GET", endpoint, nil)
|
|
if err != nil || statusCode != http.StatusOK {
|
|
t.Fatalf("Expected %d from info request, got %d", http.StatusOK, statusCode)
|
|
}
|
|
|
|
// always shown fields
|
|
stringsToCheck := []string{
|
|
"ID",
|
|
"Containers",
|
|
"Images",
|
|
"ExecutionDriver",
|
|
"LoggingDriver",
|
|
"OperatingSystem",
|
|
"NCPU",
|
|
"MemTotal",
|
|
"KernelVersion",
|
|
"Driver"}
|
|
|
|
out := string(body)
|
|
for _, linePrefix := range stringsToCheck {
|
|
if !strings.Contains(out, linePrefix) {
|
|
t.Errorf("couldn't find string %v in output", linePrefix)
|
|
}
|
|
}
|
|
|
|
logDone("container REST API - check GET /info")
|
|
}
|