mirror of
https://github.com/docker/docker-agent.git
synced 2026-11-04 10:02:15 +00:00
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
29 lines
697 B
Go
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())
|
|
}
|