MCPcopy Index your code
hub / github.com/docker/cli / TestNodeInspectWriteContext

Function TestNodeInspectWriteContext

cli/command/node/formatter_test.go:300–365  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

298}
299
300func TestNodeInspectWriteContext(t *testing.T) {
301 node := swarm.Node{
302 ID: "nodeID1",
303 Description: swarm.NodeDescription{
304 Hostname: "foobar_baz",
305 TLSInfo: swarm.TLSInfo{
306 TrustRoot: "-----BEGIN CERTIFICATE-----\ndata\n-----END CERTIFICATE-----\n",
307 CertIssuerPublicKey: []byte("pubKey"),
308 CertIssuerSubject: []byte("subject"),
309 },
310 Platform: swarm.Platform{
311 OS: "linux",
312 Architecture: "amd64",
313 },
314 Resources: swarm.Resources{
315 MemoryBytes: 1,
316 },
317 Engine: swarm.EngineDescription{
318 EngineVersion: "0.1.1",
319 },
320 },
321 Status: swarm.NodeStatus{
322 State: swarm.NodeState("ready"),
323 Addr: "1.1.1.1",
324 },
325 Spec: swarm.NodeSpec{
326 Availability: swarm.NodeAvailability("drain"),
327 Role: swarm.NodeRole("manager"),
328 },
329 }
330 out := bytes.NewBufferString("")
331 context := formatter.Context{
332 Format: newFormat("pretty", false),
333 Output: out,
334 }
335 err := inspectFormatWrite(context, []string{"nodeID1"}, func(string) (any, []byte, error) {
336 return node, nil, nil
337 })
338 if err != nil {
339 t.Fatal(err)
340 }
341 expected := `ID: nodeID1
342Hostname: foobar_baz
343Joined at: 0001-01-01 00:00:00 +0000 utc
344Status:
345 State: Ready
346 Availability: Drain
347 Address: 1.1.1.1
348Platform:
349 Operating System: linux
350 Architecture: amd64
351Resources:
352 CPUs: 0
353 Memory: 1B
354Engine Version: 0.1.1
355TLS Info:
356 TrustRoot:
357-----BEGIN CERTIFICATE-----

Callers

nothing calls this directly

Calls 3

newFormatFunction · 0.70
inspectFormatWriteFunction · 0.70
StringMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…