| 2065 | } |
| 2066 | |
| 2067 | void TestMovePath() { |
| 2068 | Status st; |
| 2069 | auto data = SetUpPreexistingData(); |
| 2070 | auto another_container = PreexistingData::RandomContainerName(rng_); |
| 2071 | CreateContainer(another_container); |
| 2072 | // When source doesn't exist. |
| 2073 | ASSERT_MOVE("missing-container/src-path", data.ContainerPath("dest-path"), ENOENT); |
| 2074 | auto missing_path1 = data.RandomDirectoryPath(rng_); |
| 2075 | ASSERT_MOVE(missing_path1, "missing-container/path", ENOENT); |
| 2076 | |
| 2077 | // But when source exists... |
| 2078 | // ...and containers are different, we get an error message telling cross-container |
| 2079 | // moves are not implemented. |
| 2080 | EXPECT_RAISES_WITH_MESSAGE_THAT( |
| 2081 | NotImplemented, |
| 2082 | HasCrossContainerNotImplementedMessage(data.ObjectPath(), |
| 2083 | "missing-container/path"), |
| 2084 | fs()->Move(data.ObjectPath(), "missing-container/path")); |
| 2085 | EXPECT_RAISES_WITH_MESSAGE_THAT( |
| 2086 | NotImplemented, |
| 2087 | HasCrossContainerNotImplementedMessage( |
| 2088 | data.ObjectPath(), ConcatAbstractPath(another_container, "path")), |
| 2089 | fs()->Move(data.ObjectPath(), ConcatAbstractPath(another_container, "path"))); |
| 2090 | AssertFileInfo(fs(), data.ObjectPath(), FileType::File); |
| 2091 | |
| 2092 | if (!WithHierarchicalNamespace()) { |
| 2093 | GTEST_SKIP() << "The rest of TestMovePath is not implemented for non-HNS scenarios"; |
| 2094 | } |
| 2095 | |
| 2096 | EXPECT_RAISES_WITH_MESSAGE_THAT( |
| 2097 | IOError, HasMissingParentDirMessage(data.Path("missing-subdir/file")), |
| 2098 | fs()->Move(data.ObjectPath(), data.Path("missing-subdir/file"))); |
| 2099 | AssertFileInfo(fs(), data.ObjectPath(), FileType::File); |
| 2100 | |
| 2101 | // src is a file and dest does not exists |
| 2102 | ASSERT_MOVE_OK(data.ObjectPath(), data.Path("file0")); |
| 2103 | ASSERT_MOVE(data.Path("file0/"), data.Path("file1"), ENOTDIR); |
| 2104 | ASSERT_MOVE(data.Path("file0"), data.Path("file1/"), ENOENT); |
| 2105 | ASSERT_MOVE(data.Path("file0/"), data.Path("file1/"), ENOTDIR); |
| 2106 | // "file0" exists |
| 2107 | |
| 2108 | // src is a file and dest exists (as a file) |
| 2109 | auto adlfs_client = |
| 2110 | datalake_service_client_->GetFileSystemClient(data.container_name); |
| 2111 | CreateFile(adlfs_client, PreexistingData::kObjectName, PreexistingData::kLoremIpsum); |
| 2112 | CreateFile(adlfs_client, "file1", PreexistingData::kLoremIpsum); |
| 2113 | ASSERT_MOVE_OK(data.ObjectPath(), data.Path("file0")); |
| 2114 | ASSERT_MOVE(data.Path("file1/"), data.Path("file0"), ENOTDIR); |
| 2115 | ASSERT_MOVE(data.Path("file1"), data.Path("file0/"), ENOTDIR); |
| 2116 | ASSERT_MOVE(data.Path("file1/"), data.Path("file0/"), ENOTDIR); |
| 2117 | // "file0" and "file1" exist |
| 2118 | |
| 2119 | // src is a file and dest exists (as an empty dir) |
| 2120 | CreateDirectory(adlfs_client, "subdir0"); |
| 2121 | ASSERT_MOVE(data.Path("file0"), data.Path("subdir0"), EISDIR); |
| 2122 | ASSERT_MOVE(data.Path("file0/"), data.Path("subdir0"), ENOTDIR); |
| 2123 | ASSERT_MOVE(data.Path("file0"), data.Path("subdir0/"), EISDIR); |
| 2124 | ASSERT_MOVE(data.Path("file0/"), data.Path("subdir0/"), ENOTDIR); |
nothing calls this directly
no test coverage detected