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
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
@ -312,6 +313,7 @@ func testStorageAPIAppendFile(t *testing.T, storage StorageAPI) {
|
|||||||
t.Fatalf("unexpected error %v", err)
|
t.Fatalf("unexpected error %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
testData := []byte("foo")
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
volumeName string
|
volumeName string
|
||||||
objectName string
|
objectName string
|
||||||
@ -319,12 +321,18 @@ func testStorageAPIAppendFile(t *testing.T, storage StorageAPI) {
|
|||||||
expectErr bool
|
expectErr bool
|
||||||
ignoreIfWindows bool
|
ignoreIfWindows bool
|
||||||
}{
|
}{
|
||||||
{"foo", "myobject", []byte("foo"), false, false},
|
{"foo", "myobject", testData, false, false},
|
||||||
{"foo", "myobject", []byte{}, false, false},
|
{"foo", "myobject-0byte", []byte{}, false, false},
|
||||||
// volume not found error.
|
// volume not found error.
|
||||||
{"bar", "myobject", []byte{}, true, false},
|
{"bar", "myobject", testData, true, false},
|
||||||
// Weird '\n' in object name
|
// Test some weird characters over the wire.
|
||||||
{"foo", "newline\n", []byte{}, false, true},
|
{"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 {
|
for i, testCase := range testCases {
|
||||||
@ -337,6 +345,17 @@ func testStorageAPIAppendFile(t *testing.T, storage StorageAPI) {
|
|||||||
if expectErr != testCase.expectErr {
|
if expectErr != testCase.expectErr {
|
||||||
t.Fatalf("case %v: error: expected: %v, got: %v", i+1, testCase.expectErr, 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