fix: harden custom QR login output
This commit is contained in:
@@ -37,6 +37,26 @@ func TestWithQRWriterRejectsNil(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestWithQRWriterRejectsTypedNil(t *testing.T) {
|
||||
var output *bytes.Buffer
|
||||
_, err := NewClient(t.TempDir(), WithQRWriter(output))
|
||||
if err == nil || err.Error() != "QR writer must not be nil" {
|
||||
t.Fatalf("error = %v, want QR writer must not be nil", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWithQRWriterAcceptsStructWriter(t *testing.T) {
|
||||
if _, err := NewClient(t.TempDir(), WithQRWriter(structWriter{})); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
type structWriter struct{}
|
||||
|
||||
func (structWriter) Write(data []byte) (int, error) {
|
||||
return len(data), nil
|
||||
}
|
||||
|
||||
func TestDefaultQRWriterIsStdout(t *testing.T) {
|
||||
client, err := NewClient(t.TempDir())
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user