mirror of
https://github.com/golang/go
synced 2024-11-22 04:34:39 -07:00
pkg: fix incorrect prints found by govet
Also, clarify some error messages R=golang-dev, r CC=golang-dev https://golang.org/cl/4548042
This commit is contained in:
parent
870791a5ac
commit
cc2fc02467
@ -72,7 +72,7 @@ func TestPublicKeySerialize(t *testing.T) {
|
|||||||
serializeBuf := bytes.NewBuffer(nil)
|
serializeBuf := bytes.NewBuffer(nil)
|
||||||
err = pk.Serialize(serializeBuf)
|
err = pk.Serialize(serializeBuf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("#%d: failed to serialize: %s", err)
|
t.Errorf("#%d: failed to serialize: %s", i, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,13 +222,13 @@ func TestEmptyMultipartRequest(t *testing.T) {
|
|||||||
func testMissingFile(t *testing.T, req *Request) {
|
func testMissingFile(t *testing.T, req *Request) {
|
||||||
f, fh, err := req.FormFile("missing")
|
f, fh, err := req.FormFile("missing")
|
||||||
if f != nil {
|
if f != nil {
|
||||||
t.Errorf("FormFile file = %q, want nil", f, nil)
|
t.Errorf("FormFile file = %q, want nil", f)
|
||||||
}
|
}
|
||||||
if fh != nil {
|
if fh != nil {
|
||||||
t.Errorf("FormFile file header = %q, want nil", fh, nil)
|
t.Errorf("FormFile file header = %q, want nil", fh)
|
||||||
}
|
}
|
||||||
if err != ErrMissingFile {
|
if err != ErrMissingFile {
|
||||||
t.Errorf("FormFile err = %q, want nil", err, ErrMissingFile)
|
t.Errorf("FormFile err = %q, want ErrMissingFile", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,7 +236,7 @@ func newTestMultipartRequest(t *testing.T) *Request {
|
|||||||
b := bytes.NewBufferString(strings.Replace(message, "\n", "\r\n", -1))
|
b := bytes.NewBufferString(strings.Replace(message, "\n", "\r\n", -1))
|
||||||
req, err := NewRequest("POST", "/", b)
|
req, err := NewRequest("POST", "/", b)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("NewRequest:", err)
|
t.Fatal("NewRequest:", err)
|
||||||
}
|
}
|
||||||
ctype := fmt.Sprintf(`multipart/form-data; boundary="%s"`, boundary)
|
ctype := fmt.Sprintf(`multipart/form-data; boundary="%s"`, boundary)
|
||||||
req.Header.Set("Content-type", ctype)
|
req.Header.Set("Content-type", ctype)
|
||||||
@ -276,7 +276,7 @@ func validateTestMultipartContents(t *testing.T, req *Request, allMem bool) {
|
|||||||
func testMultipartFile(t *testing.T, req *Request, key, expectFilename, expectContent string) multipart.File {
|
func testMultipartFile(t *testing.T, req *Request, key, expectFilename, expectContent string) multipart.File {
|
||||||
f, fh, err := req.FormFile(key)
|
f, fh, err := req.FormFile(key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("FormFile(%q):", key, err)
|
t.Fatalf("FormFile(%q): %q", key, err)
|
||||||
}
|
}
|
||||||
if fh.Filename != expectFilename {
|
if fh.Filename != expectFilename {
|
||||||
t.Errorf("filename = %q, want %q", fh.Filename, expectFilename)
|
t.Errorf("filename = %q, want %q", fh.Filename, expectFilename)
|
||||||
|
@ -376,7 +376,7 @@ func TestReadResponseCloseInMiddle(t *testing.T) {
|
|||||||
rest, err := ioutil.ReadAll(bufr)
|
rest, err := ioutil.ReadAll(bufr)
|
||||||
checkErr(err, "ReadAll on remainder")
|
checkErr(err, "ReadAll on remainder")
|
||||||
if e, g := "Next Request Here", string(rest); e != g {
|
if e, g := "Next Request Here", string(rest); e != g {
|
||||||
fatalf("for chunked=%v remainder = %q, expected %q", g, e)
|
fatalf("remainder = %q, expected %q", g, e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -385,7 +385,7 @@ func diff(t *testing.T, prefix string, have, want interface{}) {
|
|||||||
hv := reflect.ValueOf(have).Elem()
|
hv := reflect.ValueOf(have).Elem()
|
||||||
wv := reflect.ValueOf(want).Elem()
|
wv := reflect.ValueOf(want).Elem()
|
||||||
if hv.Type() != wv.Type() {
|
if hv.Type() != wv.Type() {
|
||||||
t.Errorf("%s: type mismatch %v vs %v", prefix, hv.Type(), wv.Type())
|
t.Errorf("%s: type mismatch %v want %v", prefix, hv.Type(), wv.Type())
|
||||||
}
|
}
|
||||||
for i := 0; i < hv.NumField(); i++ {
|
for i := 0; i < hv.NumField(); i++ {
|
||||||
hf := hv.Field(i).Interface()
|
hf := hv.Field(i).Interface()
|
||||||
|
@ -33,7 +33,7 @@ func TestReadForm(t *testing.T) {
|
|||||||
}
|
}
|
||||||
fd = testFile(t, f.File["fileb"][0], "fileb.txt", filebContents)
|
fd = testFile(t, f.File["fileb"][0], "fileb.txt", filebContents)
|
||||||
if _, ok := fd.(*os.File); !ok {
|
if _, ok := fd.(*os.File); !ok {
|
||||||
t.Error("file has unexpected underlying type %T", fd)
|
t.Errorf("file has unexpected underlying type %T", fd)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ func TestLookup(t *testing.T) {
|
|||||||
}
|
}
|
||||||
fi, err := os.Stat(u.HomeDir)
|
fi, err := os.Stat(u.HomeDir)
|
||||||
if err != nil || !fi.IsDirectory() {
|
if err != nil || !fi.IsDirectory() {
|
||||||
t.Errorf("expected a valid HomeDir; stat(%q): err=%v, IsDirectory=%v", err, fi.IsDirectory())
|
t.Errorf("expected a valid HomeDir; stat(%q): err=%v, IsDirectory=%v", u.HomeDir, err, fi.IsDirectory())
|
||||||
}
|
}
|
||||||
if u.Username == "" {
|
if u.Username == "" {
|
||||||
t.Fatalf("didn't get a username")
|
t.Fatalf("didn't get a username")
|
||||||
|
Loading…
Reference in New Issue
Block a user