(t *testing.T)
| 106 | } |
| 107 | |
| 108 | func TestContainerStart(t *testing.T) { |
| 109 | t.Parallel() |
| 110 | |
| 111 | client, err := newClient(t, address) |
| 112 | if err != nil { |
| 113 | t.Fatal(err) |
| 114 | } |
| 115 | defer client.Close() |
| 116 | |
| 117 | var ( |
| 118 | image Image |
| 119 | ctx, cancel = testContext(t) |
| 120 | id = t.Name() |
| 121 | ) |
| 122 | defer cancel() |
| 123 | |
| 124 | image, err = client.GetImage(ctx, testImage) |
| 125 | if err != nil { |
| 126 | t.Fatal(err) |
| 127 | } |
| 128 | container, err := client.NewContainer(ctx, id, WithNewSnapshot(id, image), WithNewSpec(oci.WithImageConfig(image), withExitStatus(7))) |
| 129 | if err != nil { |
| 130 | t.Fatal(err) |
| 131 | } |
| 132 | defer container.Delete(ctx, WithSnapshotCleanup) |
| 133 | |
| 134 | task, err := container.NewTask(ctx, empty()) |
| 135 | if err != nil { |
| 136 | t.Fatal(err) |
| 137 | } |
| 138 | defer task.Delete(ctx) |
| 139 | |
| 140 | statusC, err := task.Wait(ctx) |
| 141 | if err != nil { |
| 142 | t.Fatal(err) |
| 143 | } |
| 144 | |
| 145 | if runtime.GOOS != "windows" { |
| 146 | // task.Pid not implemented on Windows |
| 147 | if pid := task.Pid(); pid < 1 { |
| 148 | t.Errorf("invalid task pid %d", pid) |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | if err := task.Start(ctx); err != nil { |
| 153 | t.Error(err) |
| 154 | task.Delete(ctx) |
| 155 | return |
| 156 | } |
| 157 | status := <-statusC |
| 158 | code, _, err := status.Result() |
| 159 | if err != nil { |
| 160 | t.Fatal(err) |
| 161 | } |
| 162 | if code != 7 { |
| 163 | t.Errorf("expected status 7 from wait but received %d", code) |
| 164 | } |
| 165 |
nothing calls this directly
no test coverage detected
searching dependent graphs…