MCPcopy
hub / github.com/containerd/containerd / TestTaskSpec

Function TestTaskSpec

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

Source from the content-addressed store, hash-verified

2590}
2591
2592func TestTaskSpec(t *testing.T) {
2593 t.Parallel()
2594
2595 client, err := newClient(t, address)
2596 if err != nil {
2597 t.Fatal(err)
2598 }
2599 defer client.Close()
2600
2601 var (
2602 image Image
2603 ctx, cancel = testContext(t)
2604 id = t.Name()
2605 )
2606 defer cancel()
2607
2608 image, err = client.GetImage(ctx, testImage)
2609 if err != nil {
2610 t.Fatal(err)
2611 }
2612
2613 container, err := client.NewContainer(ctx, id, WithNewSnapshot(id, image), WithNewSpec(oci.WithImageConfig(image), longCommand))
2614 if err != nil {
2615 t.Fatal(err)
2616 }
2617 defer container.Delete(ctx, WithSnapshotCleanup)
2618
2619 task, err := container.NewTask(ctx, empty())
2620 if err != nil {
2621 t.Fatal(err)
2622 }
2623 defer task.Delete(ctx)
2624
2625 statusC, err := task.Wait(ctx)
2626 if err != nil {
2627 t.Fatal(err)
2628 }
2629
2630 spec, err := task.Spec(ctx)
2631 if err != nil {
2632 t.Fatal(err)
2633 }
2634 if spec == nil {
2635 t.Fatal("spec from task is nil")
2636 }
2637 direct, err := newDirectIO(ctx, false)
2638 if err != nil {
2639 t.Fatal(err)
2640 }
2641 defer direct.Delete()
2642
2643 lt, err := container.Task(ctx, direct.IOAttach)
2644 if err != nil {
2645 t.Fatal(err)
2646 }
2647
2648 spec, err = lt.Spec(ctx)
2649 if err != nil {

Callers

nothing calls this directly

Calls 15

DeleteMethod · 0.95
NewTaskMethod · 0.95
SpecMethod · 0.95
TaskMethod · 0.95
WithImageConfigFunction · 0.92
newClientFunction · 0.85
testContextFunction · 0.85
WithNewSpecFunction · 0.85
emptyFunction · 0.85
FatalMethod · 0.80
newDirectIOFunction · 0.70
CloseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…