Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions cmd/docker-trust/internal/test/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ func TerminatePrompt(ctx context.Context, t *testing.T, cmd *cobra.Command, cli
}))
cli.SetOut(outStream)

r, _, err := os.Pipe()
r, w, err := os.Pipe()
assert.NilError(t, err)

// Keep the write end alive for the duration of the test.
defer w.Close()
cli.SetIn(streams.NewIn(r))

notifyCtx, notifyCancel := context.WithCancel(ctx)
Expand Down Expand Up @@ -58,8 +61,6 @@ func TerminatePrompt(ctx context.Context, t *testing.T, cmd *cobra.Command, cli
}()
}

assert.Check(t, cli.OutBuffer().Len() > 0)

// a small delay to ensure the plugin is prompting
time.Sleep(100 * time.Microsecond)

Expand Down
7 changes: 4 additions & 3 deletions internal/test/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ func TerminatePrompt(ctx context.Context, t *testing.T, cmd *cobra.Command, cli
}))
cli.SetOut(outStream)

r, _, err := os.Pipe()
r, w, err := os.Pipe()
assert.NilError(t, err)

// Keep the write end alive for the duration of the test.
defer w.Close()
cli.SetIn(streams.NewIn(r))

notifyCtx, notifyCancel := context.WithCancel(ctx)
Expand Down Expand Up @@ -58,8 +61,6 @@ func TerminatePrompt(ctx context.Context, t *testing.T, cmd *cobra.Command, cli
}()
}

assert.Check(t, cli.OutBuffer().Len() > 0)

// a small delay to ensure the plugin is prompting
time.Sleep(100 * time.Microsecond)

Expand Down
Loading