MCPcopy
hub / github.com/containerd/containerd / TestContainerNoBinaryExists

Function TestContainerNoBinaryExists

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

Source from the content-addressed store, hash-verified

942}
943
944func TestContainerNoBinaryExists(t *testing.T) {
945 t.Parallel()
946
947 client, err := newClient(t, address)
948 if err != nil {
949 t.Fatal(err)
950 }
951 defer client.Close()
952
953 var (
954 image Image
955 ctx, cancel = testContext(t)
956 id = t.Name()
957 )
958 defer cancel()
959
960 image, err = client.GetImage(ctx, testImage)
961 if err != nil {
962 t.Fatal(err)
963 }
964
965 container, err := client.NewContainer(ctx, id,
966 WithNewSnapshot(id, image),
967 WithNewSpec(oci.WithImageConfig(image), oci.WithProcessArgs("nothing")))
968 if err != nil {
969 t.Fatal(err)
970 }
971 defer container.Delete(ctx, WithSnapshotCleanup)
972
973 task, err := container.NewTask(ctx, empty())
974 switch runtime.GOOS {
975 case "windows":
976 if err != nil {
977 t.Fatalf("failed to create task %v", err)
978 }
979 defer task.Delete(ctx, WithProcessKill)
980 if err := task.Start(ctx); err == nil {
981 t.Error("task.Start() should return an error when binary does not exist")
982 }
983 default:
984 if err == nil {
985 t.Error("NewTask should return an error when binary does not exist")
986 task.Delete(ctx)
987 }
988 }
989}
990
991func TestContainerExecNoBinaryExists(t *testing.T) {
992 t.Parallel()

Callers

nothing calls this directly

Calls 15

DeleteMethod · 0.95
NewTaskMethod · 0.95
WithImageConfigFunction · 0.92
WithProcessArgsFunction · 0.92
newClientFunction · 0.85
testContextFunction · 0.85
WithNewSpecFunction · 0.85
emptyFunction · 0.85
FatalMethod · 0.80
CloseMethod · 0.65
NameMethod · 0.65
GetImageMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…