Files
David Gageot 6276c6b9f6 feat: add --last flag for exec to print only the final answer
Buffers output across turns and emits just the last response, as text
or a JSON value, declining prompts like --json does. Also redirects
automatic model-pull diagnostics to stderr and surfaces empty-response/
tool-call metadata on remote completion events so --last can tell a
real answer from a partial one.

Assisted-By: docker-agent
2026-10-04 16:04:46 +02:00

29 lines
697 B
Go

//go:build !windows
package cli
import (
"bytes"
"os"
"testing"
"github.com/creack/pty"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/docker/docker-agent/pkg/session"
)
func TestRunLastRequiresPromptWithTerminalStdin(t *testing.T) {
master, tty, err := pty.Open()
require.NoError(t, err)
t.Cleanup(func() { _ = master.Close(); _ = tty.Close() })
old := os.Stdin
os.Stdin = tty
t.Cleanup(func() { os.Stdin = old })
var out bytes.Buffer
err = Run(t.Context(), NewPrinter(&out), Config{Last: true, OutputJSON: true}, &mockRuntime{}, session.New(), nil)
require.ErrorContains(t, err, "requires a message")
assert.Empty(t, out.String())
}