refactor(http): replace string(w.Body.Bytes()) with w.Body.String() (#18143)
Instead of type converting the Body.Bytes() to a string, we can simply call Body.String(). While we're at it, this patch also uses a simple string comparison instead of cmp.Equal() for two strings. According to the docs, they're equivalent.pull/18146/head
parent
c0fe2c30d6
commit
b7d3d21313
|
@ -1188,7 +1188,7 @@ func TestHandler_Flux_DisabledByDefault(t *testing.T) {
|
|||
}
|
||||
|
||||
exp := "Flux query service disabled. Verify flux-enabled=true in the [http] section of the InfluxDB config.\n"
|
||||
if got := string(w.Body.Bytes()); !cmp.Equal(got, exp) {
|
||||
if got := w.Body.String(); got != exp {
|
||||
t.Fatalf("unexpected body -got/+exp\n%s", cmp.Diff(got, exp))
|
||||
}
|
||||
}
|
||||
|
@ -1408,7 +1408,7 @@ func TestHandler_Flux(t *testing.T) {
|
|||
}
|
||||
|
||||
if test.expBody != "" {
|
||||
if got := string(w.Body.Bytes()); !cmp.Equal(got, test.expBody) {
|
||||
if got := w.Body.String(); got != test.expBody {
|
||||
t.Fatalf("unexpected body -got/+exp\n%s", cmp.Diff(got, test.expBody))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue