(t *testing.T)
| 1054 | } |
| 1055 | |
| 1056 | func TestWaitStoppedTask(t *testing.T) { |
| 1057 | t.Parallel() |
| 1058 | |
| 1059 | client, err := newClient(t, address) |
| 1060 | if err != nil { |
| 1061 | t.Fatal(err) |
| 1062 | } |
| 1063 | defer client.Close() |
| 1064 | |
| 1065 | var ( |
| 1066 | image Image |
| 1067 | ctx, cancel = testContext(t) |
| 1068 | id = t.Name() |
| 1069 | ) |
| 1070 | defer cancel() |
| 1071 | |
| 1072 | image, err = client.GetImage(ctx, testImage) |
| 1073 | if err != nil { |
| 1074 | t.Fatal(err) |
| 1075 | } |
| 1076 | |
| 1077 | container, err := client.NewContainer(ctx, id, WithNewSnapshot(id, image), WithNewSpec(oci.WithImageConfig(image), withExitStatus(7))) |
| 1078 | if err != nil { |
| 1079 | t.Fatal(err) |
| 1080 | } |
| 1081 | defer container.Delete(ctx, WithSnapshotCleanup) |
| 1082 | |
| 1083 | task, err := container.NewTask(ctx, empty()) |
| 1084 | if err != nil { |
| 1085 | t.Fatal(err) |
| 1086 | } |
| 1087 | defer task.Delete(ctx) |
| 1088 | |
| 1089 | statusC, err := task.Wait(ctx) |
| 1090 | if err != nil { |
| 1091 | t.Fatal(err) |
| 1092 | } |
| 1093 | |
| 1094 | if runtime.GOOS != "windows" { |
| 1095 | // Getting the pid is not currently implemented on windows |
| 1096 | if pid := task.Pid(); pid < 1 { |
| 1097 | t.Errorf("invalid task pid %d", pid) |
| 1098 | } |
| 1099 | } |
| 1100 | if err := task.Start(ctx); err != nil { |
| 1101 | t.Error(err) |
| 1102 | task.Delete(ctx) |
| 1103 | return |
| 1104 | } |
| 1105 | |
| 1106 | // wait for the task to stop then call wait again |
| 1107 | <-statusC |
| 1108 | statusC, err = task.Wait(ctx) |
| 1109 | if err != nil { |
| 1110 | t.Fatal(err) |
| 1111 | } |
| 1112 | status := <-statusC |
| 1113 | code, _, err := status.Result() |
nothing calls this directly
no test coverage detected
searching dependent graphs…