| 2085 | } |
| 2086 | |
| 2087 | void TestMovePath() { |
| 2088 | Status st; |
| 2089 | auto data = SetUpPreexistingData(); |
| 2090 | auto another_container = PreexistingData::RandomContainerName(rng_); |
| 2091 | CreateContainer(another_container); |
| 2092 | // When source doesn't exist. |
| 2093 | ASSERT_MOVE("missing-container/src-path", data.ContainerPath("dest-path"), ENOENT); |
| 2094 | auto missing_path1 = data.RandomDirectoryPath(rng_); |
| 2095 | ASSERT_MOVE(missing_path1, "missing-container/path", ENOENT); |
| 2096 | |
| 2097 | // But when source exists... |
| 2098 | // ...and containers are different, we get an error message telling cross-container |
| 2099 | // moves are not implemented. |
| 2100 | EXPECT_RAISES_WITH_MESSAGE_THAT( |
| 2101 | NotImplemented, |
| 2102 | HasCrossContainerNotImplementedMessage(data.ObjectPath(), |
| 2103 | "missing-container/path"), |
| 2104 | fs()->Move(data.ObjectPath(), "missing-container/path")); |
| 2105 | EXPECT_RAISES_WITH_MESSAGE_THAT( |
| 2106 | NotImplemented, |
| 2107 | HasCrossContainerNotImplementedMessage( |
| 2108 | data.ObjectPath(), ConcatAbstractPath(another_container, "path")), |
| 2109 | fs()->Move(data.ObjectPath(), ConcatAbstractPath(another_container, "path"))); |
| 2110 | AssertFileInfo(fs(), data.ObjectPath(), FileType::File); |
| 2111 | |
| 2112 | if (!WithHierarchicalNamespace()) { |
| 2113 | GTEST_SKIP() << "The rest of TestMovePath is not implemented for non-HNS scenarios"; |
| 2114 | } |
| 2115 | |
| 2116 | EXPECT_RAISES_WITH_MESSAGE_THAT( |
| 2117 | IOError, HasMissingParentDirMessage(data.Path("missing-subdir/file")), |
| 2118 | fs()->Move(data.ObjectPath(), data.Path("missing-subdir/file"))); |
| 2119 | AssertFileInfo(fs(), data.ObjectPath(), FileType::File); |
| 2120 | |
| 2121 | // src is a file and dest does not exists |
| 2122 | ASSERT_MOVE_OK(data.ObjectPath(), data.Path("file0")); |
| 2123 | ASSERT_MOVE(data.Path("file0/"), data.Path("file1"), ENOTDIR); |
| 2124 | ASSERT_MOVE(data.Path("file0"), data.Path("file1/"), ENOENT); |
| 2125 | ASSERT_MOVE(data.Path("file0/"), data.Path("file1/"), ENOTDIR); |
| 2126 | // "file0" exists |
| 2127 | |
| 2128 | // src is a file and dest exists (as a file) |
| 2129 | auto adlfs_client = |
| 2130 | datalake_service_client_->GetFileSystemClient(data.container_name); |
| 2131 | CreateFile(adlfs_client, PreexistingData::kObjectName, PreexistingData::kLoremIpsum); |
| 2132 | CreateFile(adlfs_client, "file1", PreexistingData::kLoremIpsum); |
| 2133 | ASSERT_MOVE_OK(data.ObjectPath(), data.Path("file0")); |
| 2134 | ASSERT_MOVE(data.Path("file1/"), data.Path("file0"), ENOTDIR); |
| 2135 | ASSERT_MOVE(data.Path("file1"), data.Path("file0/"), ENOTDIR); |
| 2136 | ASSERT_MOVE(data.Path("file1/"), data.Path("file0/"), ENOTDIR); |
| 2137 | // "file0" and "file1" exist |
| 2138 | |
| 2139 | // src is a file and dest exists (as an empty dir) |
| 2140 | CreateDirectory(adlfs_client, "subdir0"); |
| 2141 | ASSERT_MOVE(data.Path("file0"), data.Path("subdir0"), EISDIR); |
| 2142 | ASSERT_MOVE(data.Path("file0/"), data.Path("subdir0"), ENOTDIR); |
| 2143 | ASSERT_MOVE(data.Path("file0"), data.Path("subdir0/"), EISDIR); |
| 2144 | ASSERT_MOVE(data.Path("file0/"), data.Path("subdir0/"), ENOTDIR); |
nothing calls this directly
no test coverage detected