Files
mcdsl/terminal/terminal_test.go
Kyle Isom 818c0c2e14 Add ReadPasswordBytes for crypto use cases
Returns []byte so callers can zeroize the buffer after use.
Refactors internals to share readRaw between both variants.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 11:32:36 -07:00

22 lines
497 B
Go

package terminal
import (
"testing"
)
func TestReadPasswordNotATTY(t *testing.T) {
// When stdin is not a terminal (e.g. in CI), ReadPassword should
// return an error rather than hanging or panicking.
_, err := ReadPassword("Password: ")
if err == nil {
t.Fatal("expected error when stdin is not a terminal")
}
}
func TestReadPasswordBytesNotATTY(t *testing.T) {
_, err := ReadPasswordBytes("Password: ")
if err == nil {
t.Fatal("expected error when stdin is not a terminal")
}
}