mirror of
https://github.com/minio/minio.git
synced 2024-12-24 06:05:55 -05:00
add more tests to cover areas for weird object names (#13873)
continuation of #13858 to add more tests and also validate the written object data.
This commit is contained in:
parent
b9f0046ee7
commit
5b7c00ff52
@ -18,6 +18,7 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"io/ioutil"
|
||||
"net/http/httptest"
|
||||
@ -312,6 +313,7 @@ func testStorageAPIAppendFile(t *testing.T, storage StorageAPI) {
|
||||
t.Fatalf("unexpected error %v", err)
|
||||
}
|
||||
|
||||
testData := []byte("foo")
|
||||
testCases := []struct {
|
||||
volumeName string
|
||||
objectName string
|
||||
@ -319,12 +321,18 @@ func testStorageAPIAppendFile(t *testing.T, storage StorageAPI) {
|
||||
expectErr bool
|
||||
ignoreIfWindows bool
|
||||
}{
|
||||
{"foo", "myobject", []byte("foo"), false, false},
|
||||
{"foo", "myobject", []byte{}, false, false},
|
||||
{"foo", "myobject", testData, false, false},
|
||||
{"foo", "myobject-0byte", []byte{}, false, false},
|
||||
// volume not found error.
|
||||
{"bar", "myobject", []byte{}, true, false},
|
||||
// Weird '\n' in object name
|
||||
{"foo", "newline\n", []byte{}, false, true},
|
||||
{"bar", "myobject", testData, true, false},
|
||||
// Test some weird characters over the wire.
|
||||
{"foo", "newline\n", testData, false, true},
|
||||
{"foo", "newline\t", testData, false, true},
|
||||
{"foo", "newline \n", testData, false, true},
|
||||
{"foo", "newline$$$\n", testData, false, true},
|
||||
{"foo", "newline%%%\n", testData, false, true},
|
||||
{"foo", "newline \t % $ & * ^ # @ \n", testData, false, true},
|
||||
{"foo", "\n\tnewline \t % $ & * ^ # @ \n", testData, false, true},
|
||||
}
|
||||
|
||||
for i, testCase := range testCases {
|
||||
@ -337,6 +345,17 @@ func testStorageAPIAppendFile(t *testing.T, storage StorageAPI) {
|
||||
if expectErr != testCase.expectErr {
|
||||
t.Fatalf("case %v: error: expected: %v, got: %v", i+1, testCase.expectErr, expectErr)
|
||||
}
|
||||
|
||||
if !testCase.expectErr {
|
||||
data, err := storage.ReadAll(context.Background(), testCase.volumeName, testCase.objectName)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if !bytes.Equal(data, testCase.data) {
|
||||
t.Fatalf("case %v: expected %v, got %v", i+1, testCase.data, data)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user