(t *testing.T)
| 840 | } |
| 841 | |
| 842 | func TestContainerUserID(t *testing.T) { |
| 843 | t.Parallel() |
| 844 | |
| 845 | client, err := newClient(t, address) |
| 846 | if err != nil { |
| 847 | t.Fatal(err) |
| 848 | } |
| 849 | defer client.Close() |
| 850 | |
| 851 | var ( |
| 852 | image Image |
| 853 | ctx, cancel = testContext(t) |
| 854 | id = t.Name() |
| 855 | ) |
| 856 | defer cancel() |
| 857 | |
| 858 | image, err = client.GetImage(ctx, testImage) |
| 859 | if err != nil { |
| 860 | t.Fatal(err) |
| 861 | } |
| 862 | direct, err := newDirectIO(ctx, false) |
| 863 | if err != nil { |
| 864 | t.Fatal(err) |
| 865 | } |
| 866 | defer direct.Delete() |
| 867 | var ( |
| 868 | wg sync.WaitGroup |
| 869 | buf = bytes.NewBuffer(nil) |
| 870 | ) |
| 871 | wg.Go(func() { |
| 872 | io.Copy(buf, direct.Stdout) |
| 873 | }) |
| 874 | |
| 875 | // sys user in the busybox image has a uid and gid of 3. |
| 876 | container, err := client.NewContainer(ctx, id, |
| 877 | WithNewSnapshot(id, image), |
| 878 | WithNewSpec(oci.WithImageConfig(image), oci.WithUserID(3), oci.WithProcessArgs("sh", "-c", "echo $(id -u):$(id -g)")), |
| 879 | ) |
| 880 | if err != nil { |
| 881 | t.Fatal(err) |
| 882 | } |
| 883 | defer container.Delete(ctx, WithSnapshotCleanup) |
| 884 | |
| 885 | task, err := container.NewTask(ctx, direct.IOCreate) |
| 886 | if err != nil { |
| 887 | t.Fatal(err) |
| 888 | } |
| 889 | defer task.Delete(ctx) |
| 890 | |
| 891 | statusC, err := task.Wait(ctx) |
| 892 | if err != nil { |
| 893 | t.Fatal(err) |
| 894 | } |
| 895 | |
| 896 | if err := task.Start(ctx); err != nil { |
| 897 | t.Fatal(err) |
| 898 | } |
| 899 | <-statusC |
nothing calls this directly
no test coverage detected
searching dependent graphs…