MCPcopy
hub / github.com/containerd/containerd / TestContainerUpdate

Function TestContainerUpdate

integration/client/container_test.go:1671–1714  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1669}
1670
1671func TestContainerUpdate(t *testing.T) {
1672 t.Parallel()
1673
1674 ctx, cancel := testContext(t)
1675 defer cancel()
1676 id := t.Name()
1677
1678 client, err := newClient(t, address)
1679 if err != nil {
1680 t.Fatal(err)
1681 }
1682 defer client.Close()
1683
1684 container, err := client.NewContainer(ctx, id, WithNewSpec())
1685 if err != nil {
1686 t.Fatal(err)
1687 }
1688 defer container.Delete(ctx)
1689
1690 spec, err := container.Spec(ctx)
1691 if err != nil {
1692 t.Fatal(err)
1693 }
1694
1695 const hostname = "updated-hostname"
1696 spec.Hostname = hostname
1697
1698 if err := container.Update(ctx, func(ctx context.Context, client *Client, c *containers.Container) error {
1699 a, err := typeurl.MarshalAny(spec)
1700 if err != nil {
1701 return err
1702 }
1703 c.Spec = a
1704 return nil
1705 }); err != nil {
1706 t.Fatal(err)
1707 }
1708 if spec, err = container.Spec(ctx); err != nil {
1709 t.Fatal(err)
1710 }
1711 if spec.Hostname != hostname {
1712 t.Errorf("hostname %q != %q", spec.Hostname, hostname)
1713 }
1714}
1715
1716func TestContainerInfo(t *testing.T) {
1717 t.Parallel()

Callers

nothing calls this directly

Calls 11

DeleteMethod · 0.95
SpecMethod · 0.95
UpdateMethod · 0.95
testContextFunction · 0.85
newClientFunction · 0.85
WithNewSpecFunction · 0.85
FatalMethod · 0.80
NameMethod · 0.65
CloseMethod · 0.65
NewContainerMethod · 0.65
MarshalAnyMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…