(t *testing.T)
| 756 | } |
| 757 | |
| 758 | func TestDeleteRunningContainer(t *testing.T) { |
| 759 | t.Parallel() |
| 760 | |
| 761 | client, err := newClient(t, address) |
| 762 | if err != nil { |
| 763 | t.Fatal(err) |
| 764 | } |
| 765 | defer client.Close() |
| 766 | |
| 767 | var ( |
| 768 | image Image |
| 769 | ctx, cancel = testContext(t) |
| 770 | id = t.Name() |
| 771 | ) |
| 772 | defer cancel() |
| 773 | |
| 774 | image, err = client.GetImage(ctx, testImage) |
| 775 | if err != nil { |
| 776 | t.Fatal(err) |
| 777 | } |
| 778 | |
| 779 | container, err := client.NewContainer(ctx, id, WithNewSnapshot(id, image), WithNewSpec(oci.WithImageConfig(image), longCommand)) |
| 780 | if err != nil { |
| 781 | t.Fatal(err) |
| 782 | } |
| 783 | defer container.Delete(ctx, WithSnapshotCleanup) |
| 784 | |
| 785 | task, err := container.NewTask(ctx, empty()) |
| 786 | if err != nil { |
| 787 | t.Fatal(err) |
| 788 | } |
| 789 | defer task.Delete(ctx) |
| 790 | |
| 791 | statusC, err := task.Wait(ctx) |
| 792 | if err != nil { |
| 793 | t.Fatal(err) |
| 794 | } |
| 795 | |
| 796 | if err := task.Start(ctx); err != nil { |
| 797 | t.Fatal(err) |
| 798 | } |
| 799 | |
| 800 | err = container.Delete(ctx, WithSnapshotCleanup) |
| 801 | if err == nil { |
| 802 | t.Error("delete did not error with running task") |
| 803 | } |
| 804 | if !errdefs.IsFailedPrecondition(err) { |
| 805 | t.Errorf("expected error %q but received %q", errdefs.ErrFailedPrecondition, err) |
| 806 | } |
| 807 | if err := task.Kill(ctx, syscall.SIGKILL); err != nil { |
| 808 | t.Fatal(err) |
| 809 | } |
| 810 | <-statusC |
| 811 | } |
| 812 | |
| 813 | func TestContainerKill(t *testing.T) { |
| 814 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…