MCPcopy
hub / github.com/containerd/containerd / TestContainerExtensions

Function TestContainerExtensions

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

Source from the content-addressed store, hash-verified

1624}
1625
1626func TestContainerExtensions(t *testing.T) {
1627 t.Parallel()
1628
1629 ctx, cancel := testContext(t)
1630 defer cancel()
1631 id := t.Name()
1632
1633 client, err := newClient(t, address)
1634 if err != nil {
1635 t.Fatal(err)
1636 }
1637 defer client.Close()
1638
1639 ext := gogotypes.Any{TypeUrl: "test.ext.url", Value: []byte("hello")}
1640 container, err := client.NewContainer(ctx, id, WithNewSpec(), WithContainerExtension("hello", &ext))
1641 if err != nil {
1642 t.Fatal(err)
1643 }
1644 defer container.Delete(ctx)
1645
1646 checkExt := func(container Container) {
1647 cExts, err := container.Extensions(ctx)
1648 if err != nil {
1649 t.Fatal(err)
1650 }
1651 if len(cExts) != 1 {
1652 t.Errorf("expected 1 container extension")
1653 }
1654 if actual := cExts["hello"].GetTypeUrl(); actual != ext.TypeUrl {
1655 t.Errorf("got unexpected type url for extension: %s", actual)
1656 }
1657 if actual := cExts["hello"].GetValue(); !bytes.Equal(actual, ext.Value) {
1658 t.Errorf("expected extension value %q, got: %q", ext.Value, actual)
1659 }
1660 }
1661
1662 checkExt(container)
1663
1664 container, err = client.LoadContainer(ctx, container.ID())
1665 if err != nil {
1666 t.Fatal(err)
1667 }
1668 checkExt(container)
1669}
1670
1671func TestContainerUpdate(t *testing.T) {
1672 t.Parallel()

Callers

nothing calls this directly

Calls 14

DeleteMethod · 0.95
ExtensionsMethod · 0.95
IDMethod · 0.95
testContextFunction · 0.85
newClientFunction · 0.85
WithNewSpecFunction · 0.85
WithContainerExtensionFunction · 0.85
FatalMethod · 0.80
GetTypeUrlMethod · 0.80
GetValueMethod · 0.80
LoadContainerMethod · 0.80
NameMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…