(t *testing.T)
| 811 | } |
| 812 | |
| 813 | func TestContainerKill(t *testing.T) { |
| 814 | t.Parallel() |
| 815 | |
| 816 | client, err := newClient(t, address) |
| 817 | if err != nil { |
| 818 | t.Fatal(err) |
| 819 | } |
| 820 | defer client.Close() |
| 821 | |
| 822 | var ( |
| 823 | image Image |
| 824 | ctx, cancel = testContext(t) |
| 825 | id = t.Name() |
| 826 | ) |
| 827 | defer cancel() |
| 828 | |
| 829 | image, err = client.GetImage(ctx, testImage) |
| 830 | if err != nil { |
| 831 | t.Fatal(err) |
| 832 | } |
| 833 | |
| 834 | container, err := client.NewContainer(ctx, id, WithNewSnapshot(id, image), WithNewSpec(oci.WithImageConfig(image), longCommand)) |
| 835 | if err != nil { |
| 836 | t.Fatal(err) |
| 837 | } |
| 838 | defer container.Delete(ctx) |
| 839 | |
| 840 | task, err := container.NewTask(ctx, empty()) |
| 841 | if err != nil { |
| 842 | t.Fatal(err) |
| 843 | } |
| 844 | defer task.Delete(ctx) |
| 845 | |
| 846 | statusC, err := task.Wait(ctx) |
| 847 | if err != nil { |
| 848 | t.Fatal(err) |
| 849 | } |
| 850 | |
| 851 | if err := task.Start(ctx); err != nil { |
| 852 | t.Fatal(err) |
| 853 | } |
| 854 | if err := task.Kill(ctx, syscall.SIGKILL); err != nil { |
| 855 | t.Fatal(err) |
| 856 | } |
| 857 | <-statusC |
| 858 | |
| 859 | err = task.Kill(ctx, syscall.SIGTERM) |
| 860 | if err == nil { |
| 861 | t.Fatal("second call to kill should return an error") |
| 862 | } |
| 863 | if !errdefs.IsNotFound(err) { |
| 864 | t.Errorf("expected error %q but received %q", errdefs.ErrNotFound, err) |
| 865 | } |
| 866 | } |
| 867 | |
| 868 | func TestKillContainerDeletedByRunc(t *testing.T) { |
| 869 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…