The majority already did so, but a few used %v.
Compared with %v using %q escapes any control characters ensuring they are
visible in the logs (otherwise they can cause scrolling and overwriting etc).
The %q formatter also includes the surrounding "s making the manual use of []
to wrap/delimit the %v output unnecessary.
Signed-off-by: Ian Campbell <ian.campbell@docker.com>
| ... | ... |
@@ -144,7 +144,7 @@ func TestJSONMessageDisplay(t *testing.T) {
|
| 144 | 144 |
t.Fatal(err) |
| 145 | 145 |
} |
| 146 | 146 |
if data.String() != expectedMessages[0] {
|
| 147 |
- t.Fatalf("Expected [%v], got [%v]", expectedMessages[0], data.String())
|
|
| 147 |
+ t.Fatalf("Expected %q, got %q", expectedMessages[0], data.String())
|
|
| 148 | 148 |
} |
| 149 | 149 |
// With terminal |
| 150 | 150 |
data = bytes.NewBuffer([]byte{})
|
| ... | ... |
@@ -152,7 +152,7 @@ func TestJSONMessageDisplay(t *testing.T) {
|
| 152 | 152 |
t.Fatal(err) |
| 153 | 153 |
} |
| 154 | 154 |
if data.String() != expectedMessages[1] {
|
| 155 |
- t.Fatalf("Expected [%v], got [%v]", expectedMessages[1], data.String())
|
|
| 155 |
+ t.Fatalf("Expected %q, got %q", expectedMessages[1], data.String())
|
|
| 156 | 156 |
} |
| 157 | 157 |
} |
| 158 | 158 |
} |
| ... | ... |
@@ -164,13 +164,13 @@ func TestJSONMessageDisplayWithJSONError(t *testing.T) {
|
| 164 | 164 |
|
| 165 | 165 |
err := jsonMessage.Display(data, true) |
| 166 | 166 |
if err == nil || err.Error() != "Can't find it" {
|
| 167 |
- t.Fatalf("Expected a JSONError 404, got [%v]", err)
|
|
| 167 |
+ t.Fatalf("Expected a JSONError 404, got %q", err)
|
|
| 168 | 168 |
} |
| 169 | 169 |
|
| 170 | 170 |
jsonMessage = JSONMessage{Error: &JSONError{401, "Anything"}}
|
| 171 | 171 |
err = jsonMessage.Display(data, true) |
| 172 | 172 |
if err == nil || err.Error() != "Authentication is required." {
|
| 173 |
- t.Fatalf("Expected an error [Authentication is required.], got [%v]", err)
|
|
| 173 |
+ t.Fatalf("Expected an error \"Authentication is required.\", got %q", err)
|
|
| 174 | 174 |
} |
| 175 | 175 |
} |
| 176 | 176 |
|
| ... | ... |
@@ -183,7 +183,7 @@ func TestDisplayJSONMessagesStreamInvalidJSON(t *testing.T) {
|
| 183 | 183 |
inFd, _ = term.GetFdInfo(reader) |
| 184 | 184 |
|
| 185 | 185 |
if err := DisplayJSONMessagesStream(reader, data, inFd, false, nil); err == nil && err.Error()[:17] != "invalid character" {
|
| 186 |
- t.Fatalf("Should have thrown an error (invalid character in ..), got [%v]", err)
|
|
| 186 |
+ t.Fatalf("Should have thrown an error (invalid character in ..), got %q", err)
|
|
| 187 | 187 |
} |
| 188 | 188 |
} |
| 189 | 189 |
|
| ... | ... |
@@ -228,7 +228,7 @@ func TestDisplayJSONMessagesStream(t *testing.T) {
|
| 228 | 228 |
t.Fatal(err) |
| 229 | 229 |
} |
| 230 | 230 |
if data.String() != expectedMessages[0] {
|
| 231 |
- t.Fatalf("Expected an [%v], got [%v]", expectedMessages[0], data.String())
|
|
| 231 |
+ t.Fatalf("Expected an %q, got %q", expectedMessages[0], data.String())
|
|
| 232 | 232 |
} |
| 233 | 233 |
|
| 234 | 234 |
// With terminal |
| ... | ... |
@@ -238,7 +238,7 @@ func TestDisplayJSONMessagesStream(t *testing.T) {
|
| 238 | 238 |
t.Fatal(err) |
| 239 | 239 |
} |
| 240 | 240 |
if data.String() != expectedMessages[1] {
|
| 241 |
- t.Fatalf("Expected an [%v], got [%v]", expectedMessages[1], data.String())
|
|
| 241 |
+ t.Fatalf("Expected an %q, got %q", expectedMessages[1], data.String())
|
|
| 242 | 242 |
} |
| 243 | 243 |
} |
| 244 | 244 |
|