Merge pull request '[agent/codex:gpt-5.4-mini] Read ~/spec/code/core/go/cli/RFC.md fully. Find ONE feature ...' (#29) from agent/read---spec-code-core-go-cli-rfc-md-full into dev
Some checks failed
Security Scan / security (push) Has been cancelled

This commit is contained in:
Virgil 2026-04-02 03:42:30 +00:00
commit e5e1731b3d
2 changed files with 20 additions and 1 deletions

View file

@ -13,7 +13,14 @@ import (
var stdin io.Reader = os.Stdin
// SetStdin overrides the default stdin reader for testing.
func SetStdin(r io.Reader) { stdin = r }
// Pass nil to restore the real os.Stdin reader.
func SetStdin(r io.Reader) {
if r == nil {
stdin = os.Stdin
return
}
stdin = r
}
// newReader wraps stdin in a bufio.Reader if it isn't one already.
func newReader() *bufio.Reader {

View file

@ -1,6 +1,7 @@
package cli
import (
"os"
"strings"
"testing"
@ -50,3 +51,14 @@ func TestMultiSelect_Good(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, []string{"a", "c"}, vals)
}
func TestSetStdin_Good_ResetNil(t *testing.T) {
original := stdin
t.Cleanup(func() { stdin = original })
SetStdin(strings.NewReader("hello\n"))
assert.NotSame(t, os.Stdin, stdin)
SetStdin(nil)
assert.Same(t, os.Stdin, stdin)
}