|
|
|
@ -1069,70 +1069,53 @@ func TestPosixReadFile(t *testing.T) { |
|
|
|
|
volume, "path/to/my/object", 0, 5, |
|
|
|
|
[]byte("hello"), nil, |
|
|
|
|
}, |
|
|
|
|
// One path segment length is 255 chars long. - 3
|
|
|
|
|
{ |
|
|
|
|
volume, "path/to/my/object000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", |
|
|
|
|
0, 5, []byte("hello"), nil}, |
|
|
|
|
// Whole path is 1024 characters long, success case. - 4
|
|
|
|
|
{ |
|
|
|
|
volume, "level0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001/level0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002/level0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003/object000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", |
|
|
|
|
0, 5, []byte("hello"), |
|
|
|
|
func() error { |
|
|
|
|
// On darwin HFS does not support > 1024 characters.
|
|
|
|
|
if runtime.GOOS == "darwin" { |
|
|
|
|
return errFileNameTooLong |
|
|
|
|
} |
|
|
|
|
// On all other platforms return success.
|
|
|
|
|
return nil |
|
|
|
|
}(), |
|
|
|
|
}, |
|
|
|
|
// Object is a directory. - 5
|
|
|
|
|
// Object is a directory. - 3
|
|
|
|
|
{ |
|
|
|
|
volume, "object-as-dir", |
|
|
|
|
0, 5, nil, errIsNotRegular}, |
|
|
|
|
// One path segment length is > 255 chars long. - 6
|
|
|
|
|
// One path segment length is > 255 chars long. - 4
|
|
|
|
|
{ |
|
|
|
|
volume, "path/to/my/object0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", |
|
|
|
|
0, 5, nil, errFileNameTooLong}, |
|
|
|
|
// Path length is > 1024 chars long. - 7
|
|
|
|
|
// Path length is > 1024 chars long. - 5
|
|
|
|
|
{ |
|
|
|
|
volume, "level0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001/level0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002/level0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003/object000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", |
|
|
|
|
0, 5, nil, errFileNameTooLong}, |
|
|
|
|
// Buffer size greater than object size. - 8
|
|
|
|
|
// Buffer size greater than object size. - 6
|
|
|
|
|
{ |
|
|
|
|
volume, "myobject", 0, 16, |
|
|
|
|
[]byte("hello, world"), |
|
|
|
|
io.ErrUnexpectedEOF, |
|
|
|
|
}, |
|
|
|
|
// Reading from an offset success. - 9
|
|
|
|
|
// Reading from an offset success. - 7
|
|
|
|
|
{ |
|
|
|
|
volume, "myobject", 7, 5, |
|
|
|
|
[]byte("world"), nil, |
|
|
|
|
}, |
|
|
|
|
// Reading from an object but buffer size greater. - 10
|
|
|
|
|
// Reading from an object but buffer size greater. - 8
|
|
|
|
|
{ |
|
|
|
|
volume, "myobject", |
|
|
|
|
7, 8, |
|
|
|
|
[]byte("world"), |
|
|
|
|
io.ErrUnexpectedEOF, |
|
|
|
|
}, |
|
|
|
|
// Seeking ahead returns io.EOF. - 11
|
|
|
|
|
// Seeking ahead returns io.EOF. - 9
|
|
|
|
|
{ |
|
|
|
|
volume, "myobject", 14, 1, nil, io.EOF, |
|
|
|
|
}, |
|
|
|
|
// Empty volume name. - 12
|
|
|
|
|
// Empty volume name. - 10
|
|
|
|
|
{ |
|
|
|
|
"", "myobject", 14, 1, nil, errVolumeNotFound, |
|
|
|
|
}, |
|
|
|
|
// Empty filename name. - 13
|
|
|
|
|
// Empty filename name. - 11
|
|
|
|
|
{ |
|
|
|
|
volume, "", 14, 1, nil, errIsNotRegular, |
|
|
|
|
}, |
|
|
|
|
// Non existent volume name - 14.
|
|
|
|
|
// Non existent volume name - 12
|
|
|
|
|
{ |
|
|
|
|
"abcd", "", 14, 1, nil, errVolumeNotFound, |
|
|
|
|
}, |
|
|
|
|
// Non existent filename - 15.
|
|
|
|
|
// Non existent filename - 13
|
|
|
|
|
{ |
|
|
|
|
volume, "abcd", 14, 1, nil, errFileNotFound, |
|
|
|
|
}, |
|
|
|
@ -1361,8 +1344,7 @@ func TestPosixAppendFile(t *testing.T) { |
|
|
|
|
{"myobject", nil}, |
|
|
|
|
// TestPosix to use same path of previously created file.
|
|
|
|
|
{"path/to/my/testobject", nil}, |
|
|
|
|
// One path segment length is 255 chars long.
|
|
|
|
|
{"path/to/my/object000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", nil}, |
|
|
|
|
// TestPosix to use object is a directory now.
|
|
|
|
|
{"object-as-dir", errIsNotRegular}, |
|
|
|
|
// path segment uses previously uploaded object.
|
|
|
|
|
{"myobject/testobject", errFileAccessDenied}, |
|
|
|
@ -1372,17 +1354,6 @@ func TestPosixAppendFile(t *testing.T) { |
|
|
|
|
{"level0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001/level0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002/level0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003/object000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", errFileNameTooLong}, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Add path length > 1024 test specially as OS X system does not support 1024 long path.
|
|
|
|
|
err = errFileNameTooLong |
|
|
|
|
if runtime.GOOS != "darwin" { |
|
|
|
|
err = nil |
|
|
|
|
} |
|
|
|
|
// path length is 1024 chars long.
|
|
|
|
|
testCases = append(testCases, struct { |
|
|
|
|
fileName string |
|
|
|
|
expectedErr error |
|
|
|
|
}{"level0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001/level0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002/level0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003/object000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", err}) |
|
|
|
|
|
|
|
|
|
for i, testCase := range testCases { |
|
|
|
|
if err = posixStorage.AppendFile("success-vol", testCase.fileName, []byte("hello, world")); err != testCase.expectedErr { |
|
|
|
|
t.Errorf("Case: %d, expected: %s, got: %s", i+1, testCase.expectedErr, err) |
|
|
|
|