Filter out internal object prefix during listing (#4435)

We use ZZZZ-Minio/ prefix internally in our GCS gateway which should be
filtered out in the response to ListObjects.
This commit is contained in:
Krishnan Parthasarathi
2017-06-06 06:13:53 +00:00
committed by Harshavardhana
parent 9bd0eb1a9e
commit 8085ba4494
2 changed files with 42 additions and 2 deletions

View File

@@ -129,3 +129,38 @@ func TestValidGCSProjectID(t *testing.T) {
}
}
}
// Test for isGCSPrefix
func TestIsGCSPrefix(t *testing.T) {
testCases := []struct {
prefix string
expectedRes bool
}{
// Regular prefix without a trailing slash
{
prefix: "hello",
expectedRes: false,
},
// Regular prefix with a trailing slash
{
prefix: "hello/",
expectedRes: false,
},
// GCS prefix without a trailing slash
{
prefix: ZZZZMinioPrefix,
expectedRes: true,
},
// GCS prefix with a trailing slash
{
prefix: ZZZZMinioPrefix + "/",
expectedRes: true,
},
}
for i, tc := range testCases {
if actualRes := isGCSPrefix(tc.prefix); actualRes != tc.expectedRes {
t.Errorf("%d: Expected isGCSPrefix to return %v but got %v", i, tc.expectedRes, actualRes)
}
}
}