mirror of
https://github.com/restic/restic.git
synced 2025-12-11 18:47:50 +00:00
termstatus: fully wrap reading password from terminal
This commit is contained in:
@@ -3,6 +3,7 @@ package termstatus
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"testing"
|
||||
@@ -76,3 +77,13 @@ func TestSanitizeLines(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
type errorReader struct{ err error }
|
||||
|
||||
func (r *errorReader) Read([]byte) (int, error) { return 0, r.err }
|
||||
|
||||
func TestReadPassword(t *testing.T) {
|
||||
want := errors.New("foo")
|
||||
_, err := readPassword(&errorReader{want})
|
||||
rtest.Assert(t, errors.Is(err, want), "wrong error %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user