| 1 | package ssh_config |
| 2 | |
| 3 | import ( |
| 4 | "errors" |
| 5 | "testing" |
| 6 | ) |
| 7 | |
| 8 | type errReader struct { |
| 9 | } |
| 10 | |
| 11 | func (b *errReader) Read(p []byte) (n int, err error) { |
| 12 | return 0, errors.New("read error occurred") |
| 13 | } |
| 14 | |
| 15 | func TestIOError(t *testing.T) { |
| 16 | buf := &errReader{} |
| 17 | _, err := Decode(buf, false) |
| 18 | if err == nil { |
| 19 | t.Fatal("expected non-nil err, got nil") |
| 20 | } |
| 21 | if err.Error() != "read error occurred" { |
| 22 | t.Errorf("expected read error msg, got %v", err) |
| 23 | } |
| 24 | } |