2021-04-18 15:41:13 -04:00
|
|
|
// Copyright (c) 2015-2021 MinIO, Inc.
|
|
|
|
//
|
|
|
|
// This file is part of MinIO Object Storage stack
|
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Affero General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2018-01-13 12:13:02 -05:00
|
|
|
|
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Tests - mkdirAll()
|
|
|
|
func TestOSMkdirAll(t *testing.T) {
|
2020-06-12 23:04:01 -04:00
|
|
|
// create xlStorage test setup
|
2022-07-25 15:37:26 -04:00
|
|
|
_, path, err := newXLStorageTestSetup(t)
|
2018-01-13 12:13:02 -05:00
|
|
|
if err != nil {
|
2020-06-12 23:04:01 -04:00
|
|
|
t.Fatalf("Unable to create xlStorage test setup, %s", err)
|
2018-01-13 12:13:02 -05:00
|
|
|
}
|
|
|
|
|
2022-01-02 12:15:06 -05:00
|
|
|
if err = mkdirAll("", 0o777); err != errInvalidArgument {
|
2018-01-13 12:13:02 -05:00
|
|
|
t.Fatal("Unexpected error", err)
|
|
|
|
}
|
|
|
|
|
2022-01-02 12:15:06 -05:00
|
|
|
if err = mkdirAll(pathJoin(path, "my-obj-del-0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"), 0o777); err != errFileNameTooLong {
|
2018-01-13 12:13:02 -05:00
|
|
|
t.Fatal("Unexpected error", err)
|
|
|
|
}
|
|
|
|
|
2022-01-02 12:15:06 -05:00
|
|
|
if err = mkdirAll(pathJoin(path, "success-vol", "success-object"), 0o777); err != nil {
|
2018-01-13 12:13:02 -05:00
|
|
|
t.Fatal("Unexpected error", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Tests - renameAll()
|
|
|
|
func TestOSRenameAll(t *testing.T) {
|
2020-06-12 23:04:01 -04:00
|
|
|
// create xlStorage test setup
|
2022-07-25 15:37:26 -04:00
|
|
|
_, path, err := newXLStorageTestSetup(t)
|
2018-01-13 12:13:02 -05:00
|
|
|
if err != nil {
|
2020-06-12 23:04:01 -04:00
|
|
|
t.Fatalf("Unable to create xlStorage test setup, %s", err)
|
2018-01-13 12:13:02 -05:00
|
|
|
}
|
|
|
|
|
2022-01-02 12:15:06 -05:00
|
|
|
if err = mkdirAll(pathJoin(path, "testvolume1"), 0o777); err != nil {
|
2018-01-13 12:13:02 -05:00
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if err = renameAll("", "foo"); err != errInvalidArgument {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if err = renameAll("foo", ""); err != errInvalidArgument {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if err = renameAll(pathJoin(path, "testvolume1"), pathJoin(path, "testvolume2")); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2018-04-10 12:36:37 -04:00
|
|
|
if err = renameAll(pathJoin(path, "testvolume1"), pathJoin(path, "testvolume2")); err != errFileNotFound {
|
2018-01-13 12:13:02 -05:00
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2018-04-10 12:36:37 -04:00
|
|
|
if err = renameAll(pathJoin(path, "my-obj-del-0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"), pathJoin(path, "testvolume2")); err != errFileNameTooLong {
|
2018-01-13 12:13:02 -05:00
|
|
|
t.Fatal("Unexpected error", err)
|
|
|
|
}
|
2018-04-10 12:36:37 -04:00
|
|
|
if err = renameAll(pathJoin(path, "testvolume1"), pathJoin(path, "my-obj-del-0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001")); err != errFileNameTooLong {
|
2018-01-13 12:13:02 -05:00
|
|
|
t.Fatal("Unexpected error", err)
|
|
|
|
}
|
|
|
|
}
|