From d8a11c8f4b1d623271951f535921d268e1a9cf49 Mon Sep 17 00:00:00 2001 From: Bala FA Date: Fri, 6 Oct 2017 17:00:15 -0700 Subject: [PATCH] fix build failure for go1.9 (#4872) --- .travis.yml | 1 + appveyor.yml | 2 +- cmd/posix_test.go | 48 +++++++++++++++++++++++------------------------ 3 files changed, 25 insertions(+), 26 deletions(-) diff --git a/.travis.yml b/.travis.yml index 61d16ebb0..6ffb1459e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,4 +27,5 @@ after_success: - bash <(curl -s https://codecov.io/bash) go: +- 1.9.x - 1.8.x diff --git a/appveyor.yml b/appveyor.yml index 60e6c898e..c6ecd38ba 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -12,7 +12,7 @@ clone_folder: c:\gopath\src\github.com\minio\minio # Environment variables environment: GOPATH: c:\gopath - GOROOT: c:\go18 + GOROOT: c:\go # scripts that run after cloning repository install: diff --git a/cmd/posix_test.go b/cmd/posix_test.go index 952705335..1e2ff2977 100644 --- a/cmd/posix_test.go +++ b/cmd/posix_test.go @@ -1016,43 +1016,23 @@ func TestPosixReadFile(t *testing.T) { []byte("world"), io.ErrUnexpectedEOF, }, - // Seeking into a wrong offset, return PathError. - 11 - { - volume, "myobject", - -1, 5, - nil, - func() error { - if runtime.GOOS == globalWindowsOSName { - return &os.PathError{ - Op: "read", - Path: slashpath.Join(path, "success-vol", "myobject"), - Err: syscall.Errno(0x57), // invalid parameter - } - } - return &os.PathError{ - Op: "read", - Path: slashpath.Join(path, "success-vol", "myobject"), - Err: os.ErrInvalid, - } - }(), - }, - // Seeking ahead returns io.EOF. - 12 + // Seeking ahead returns io.EOF. - 11 { volume, "myobject", 14, 1, nil, io.EOF, }, - // Empty volume name. - 13 + // Empty volume name. - 12 { "", "myobject", 14, 1, nil, errInvalidArgument, }, - // Empty filename name. - 14 + // Empty filename name. - 13 { volume, "", 14, 1, nil, errIsNotRegular, }, - // Non existent volume name - 15. + // Non existent volume name - 14. { "abcd", "", 14, 1, nil, errVolumeNotFound, }, - // Non existent filename - 16. + // Non existent filename - 15. { volume, "abcd", 14, 1, nil, errFileNotFound, }, @@ -1069,6 +1049,24 @@ func TestPosixReadFile(t *testing.T) { } } + // Check PathError specially. + { + buf := make([]byte, 5) + if _, err = posixStorage.ReadFile(volume, "myobject", -1, buf, nil); err != nil { + isPathError := false + switch err.(type) { + case *os.PathError: + isPathError = true + } + + if !isPathError { + t.Fatalf("expected: , got: %v", err) + } + } else { + t.Fatalf("expected: , got: ") + } + } + // Following block validates all ReadFile test cases. for i, testCase := range testCases { var n int64