(t *testing.T)
| 1390 | } |
| 1391 | |
| 1392 | func TestContainerExitedAtSet(t *testing.T) { |
| 1393 | t.Parallel() |
| 1394 | |
| 1395 | client, err := newClient(t, address) |
| 1396 | if err != nil { |
| 1397 | t.Fatal(err) |
| 1398 | } |
| 1399 | defer client.Close() |
| 1400 | |
| 1401 | var ( |
| 1402 | image Image |
| 1403 | ctx, cancel = testContext(t) |
| 1404 | id = t.Name() |
| 1405 | ) |
| 1406 | defer cancel() |
| 1407 | |
| 1408 | image, err = client.GetImage(ctx, testImage) |
| 1409 | if err != nil { |
| 1410 | t.Fatal(err) |
| 1411 | } |
| 1412 | |
| 1413 | container, err := client.NewContainer(ctx, id, WithNewSnapshot(id, image), WithNewSpec(oci.WithImageConfig(image), withTrue())) |
| 1414 | if err != nil { |
| 1415 | t.Fatal(err) |
| 1416 | } |
| 1417 | defer container.Delete(ctx, WithSnapshotCleanup) |
| 1418 | |
| 1419 | task, err := container.NewTask(ctx, empty()) |
| 1420 | if err != nil { |
| 1421 | t.Fatal(err) |
| 1422 | } |
| 1423 | defer task.Delete(ctx) |
| 1424 | |
| 1425 | statusC, err := task.Wait(ctx) |
| 1426 | if err != nil { |
| 1427 | t.Error(err) |
| 1428 | } |
| 1429 | |
| 1430 | startTime := time.Now() |
| 1431 | if err := task.Start(ctx); err != nil { |
| 1432 | t.Fatal(err) |
| 1433 | } |
| 1434 | |
| 1435 | status := <-statusC |
| 1436 | code, _, err := status.Result() |
| 1437 | if code != 0 { |
| 1438 | t.Errorf("expected status 0 but received %d (err: %v)", code, err) |
| 1439 | } |
| 1440 | |
| 1441 | if s, err := task.Status(ctx); err != nil { |
| 1442 | t.Errorf("failed to retrieve status: %v", err) |
| 1443 | } else if s.ExitTime.After(startTime) == false { |
| 1444 | t.Errorf("exit time is not after start time: %v <= %v", startTime, s.ExitTime) |
| 1445 | } |
| 1446 | |
| 1447 | if _, err := task.Delete(ctx); err != nil { |
| 1448 | t.Fatal(err) |
| 1449 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…