github.com/gondor/docker@v1.9.0-rc1/integration-cli/docker_api_inspect_unix_test.go (about)

     1  // +build !windows
     2  
     3  package main
     4  
     5  import (
     6  	"encoding/json"
     7  	"fmt"
     8  	"net/http"
     9  
    10  	"github.com/go-check/check"
    11  )
    12  
    13  // #16665
    14  func (s *DockerSuite) TestInspectApiCpusetInConfigPre120(c *check.C) {
    15  	testRequires(c, DaemonIsLinux)
    16  	testRequires(c, cgroupCpuset)
    17  
    18  	name := "cpusetinconfig-pre120"
    19  	dockerCmd(c, "run", "--name", name, "--cpuset", "0-1", "busybox", "true")
    20  
    21  	status, body, err := sockRequest("GET", fmt.Sprintf("/v1.19/containers/%s/json", name), nil)
    22  	c.Assert(status, check.Equals, http.StatusOK)
    23  	c.Assert(err, check.IsNil)
    24  
    25  	var inspectJSON map[string]interface{}
    26  	if err = json.Unmarshal(body, &inspectJSON); err != nil {
    27  		c.Fatalf("unable to unmarshal body for version 1.19: %v", err)
    28  	}
    29  
    30  	config, ok := inspectJSON["Config"]
    31  	if !ok {
    32  		c.Fatal("Unable to find 'Config'")
    33  	}
    34  	cfg := config.(map[string]interface{})
    35  	if _, ok := cfg["Cpuset"]; !ok {
    36  		c.Fatal("Api version 1.19 expected to include Cpuset in 'Config'")
    37  	}
    38  }