| 114 | } |
| 115 | |
| 116 | func TestWrapf(t *testing.T) { |
| 117 | tests := []struct { |
| 118 | err error |
| 119 | message string |
| 120 | want string |
| 121 | }{ |
| 122 | {io.EOF, "read error", "read error: EOF"}, |
| 123 | {Wrapf(io.EOF, "read error without format specifiers"), "client error", "client error: read error without format specifiers: EOF"}, |
| 124 | {Wrapf(io.EOF, "read error with %d format specifier", 1), "client error", "client error: read error with 1 format specifier: EOF"}, |
| 125 | } |
| 126 | |
| 127 | for _, tt := range tests { |
| 128 | got := Wrapf(tt.err, tt.message).Error() |
| 129 | if got != tt.want { |
| 130 | t.Errorf("Wrapf(%v, %q): got: %v, want %v", tt.err, tt.message, got, tt.want) |
| 131 | } |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | func TestErrorf(t *testing.T) { |
| 136 | tests := []struct { |