github.com/portworx/docker@v1.12.1/api/client/service/inspect_test.go (about) 1 package service 2 3 import ( 4 "bytes" 5 "strings" 6 "testing" 7 "time" 8 9 "github.com/docker/engine-api/types/swarm" 10 ) 11 12 func TestPrettyPrintWithNoUpdateConfig(t *testing.T) { 13 b := new(bytes.Buffer) 14 15 endpointSpec := &swarm.EndpointSpec{ 16 Mode: "vip", 17 Ports: []swarm.PortConfig{ 18 { 19 Protocol: swarm.PortConfigProtocolTCP, 20 TargetPort: 5000, 21 }, 22 }, 23 } 24 25 two := uint64(2) 26 27 s := swarm.Service{ 28 ID: "de179gar9d0o7ltdybungplod", 29 Meta: swarm.Meta{ 30 Version: swarm.Version{Index: 315}, 31 CreatedAt: time.Now(), 32 UpdatedAt: time.Now(), 33 }, 34 Spec: swarm.ServiceSpec{ 35 Annotations: swarm.Annotations{ 36 Name: "my_service", 37 Labels: map[string]string{"com.label": "foo"}, 38 }, 39 TaskTemplate: swarm.TaskSpec{ 40 ContainerSpec: swarm.ContainerSpec{ 41 Image: "foo/bar@sha256:this_is_a_test", 42 }, 43 }, 44 Mode: swarm.ServiceMode{ 45 Replicated: &swarm.ReplicatedService{ 46 Replicas: &two, 47 }, 48 }, 49 UpdateConfig: nil, 50 Networks: []swarm.NetworkAttachmentConfig{ 51 { 52 Target: "5vpyomhb6ievnk0i0o60gcnei", 53 Aliases: []string{"web"}, 54 }, 55 }, 56 EndpointSpec: endpointSpec, 57 }, 58 Endpoint: swarm.Endpoint{ 59 Spec: *endpointSpec, 60 Ports: []swarm.PortConfig{ 61 { 62 Protocol: swarm.PortConfigProtocolTCP, 63 TargetPort: 5000, 64 PublishedPort: 30000, 65 }, 66 }, 67 VirtualIPs: []swarm.EndpointVirtualIP{ 68 { 69 NetworkID: "6o4107cj2jx9tihgb0jyts6pj", 70 Addr: "10.255.0.4/16", 71 }, 72 }, 73 }, 74 UpdateStatus: swarm.UpdateStatus{ 75 StartedAt: time.Now(), 76 CompletedAt: time.Now(), 77 }, 78 } 79 80 printService(b, s) 81 if strings.Contains(b.String(), "UpdateStatus") { 82 t.Fatal("Pretty print failed before parsing UpdateStatus") 83 } 84 }