(t *testing.T)
| 2729 | } |
| 2730 | |
| 2731 | func TestContainerPTY(t *testing.T) { |
| 2732 | t.Parallel() |
| 2733 | |
| 2734 | client, err := newClient(t, address) |
| 2735 | if err != nil { |
| 2736 | t.Fatal(err) |
| 2737 | } |
| 2738 | defer client.Close() |
| 2739 | |
| 2740 | var ( |
| 2741 | image Image |
| 2742 | ctx, cancel = testContext(t) |
| 2743 | id = t.Name() |
| 2744 | ) |
| 2745 | defer cancel() |
| 2746 | |
| 2747 | image, err = client.GetImage(ctx, testImage) |
| 2748 | if err != nil { |
| 2749 | t.Fatal(err) |
| 2750 | } |
| 2751 | |
| 2752 | container, err := client.NewContainer(ctx, id, WithNewSnapshot(id, image), WithNewSpec(oci.WithImageConfig(image), oci.WithTTY, withProcessArgs("echo", "hello"))) |
| 2753 | if err != nil { |
| 2754 | t.Fatal(err) |
| 2755 | } |
| 2756 | defer container.Delete(ctx, WithSnapshotCleanup) |
| 2757 | |
| 2758 | buf := bytes.NewBuffer(nil) |
| 2759 | task, err := container.NewTask(ctx, cio.NewCreator(withStdout(buf), withProcessTTY())) |
| 2760 | if err != nil { |
| 2761 | t.Fatal(err) |
| 2762 | } |
| 2763 | defer task.Delete(ctx) |
| 2764 | |
| 2765 | statusC, err := task.Wait(ctx) |
| 2766 | if err != nil { |
| 2767 | t.Error(err) |
| 2768 | } |
| 2769 | |
| 2770 | if err := task.Start(ctx); err != nil { |
| 2771 | t.Fatal(err) |
| 2772 | } |
| 2773 | |
| 2774 | <-statusC |
| 2775 | |
| 2776 | if _, err := task.Delete(ctx); err != nil { |
| 2777 | t.Fatal(err) |
| 2778 | } |
| 2779 | |
| 2780 | tries := 1 |
| 2781 | if runtime.GOOS == "windows" { |
| 2782 | // TODO: Fix flakiness on Window by checking for race in writing to buffer |
| 2783 | tries += 2 |
| 2784 | } |
| 2785 | |
| 2786 | for { |
| 2787 | out := buf.String() |
| 2788 | if strings.ContainsAny(fmt.Sprintf("%#q", out), `\x00`) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…