diff --git a/interfaces/kits/js/src/mod_fs/properties/move_core.cpp b/interfaces/kits/js/src/mod_fs/properties/move_core.cpp index 56961567c88d1b6a4e52373b245f70b01b7eac63..a0b823ea18493c5e54af1a8c4d4fedd85f2088c5 100644 --- a/interfaces/kits/js/src/mod_fs/properties/move_core.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/move_core.cpp @@ -147,14 +147,8 @@ static int RenameFile(const string &src, const string &dest) static int MoveFile(const string &src, const string &dest, int mode) { uv_fs_t access_req; - int ret = uv_fs_access(nullptr, &access_req, src.c_str(), W_OK, nullptr); - if (ret < 0) { - HILOGE("Failed to move src file due to doesn't exist or hasn't write permission"); - uv_fs_req_cleanup(&access_req); - return ret; - } if (mode == MODE_THROW_ERR) { - ret = uv_fs_access(nullptr, &access_req, dest.c_str(), 0, nullptr); + int ret = uv_fs_access(nullptr, &access_req, dest.c_str(), 0, nullptr); uv_fs_req_cleanup(&access_req); if (ret == 0) { HILOGE("Failed to move file due to existing destPath with MODE_THROW_ERR."); diff --git a/interfaces/kits/js/src/mod_fs/properties/movedir_core.cpp b/interfaces/kits/js/src/mod_fs/properties/movedir_core.cpp index fb357ff05a3a69c00db190eb57a16472988fd709..f882c1aa2e45e191eaed247f4161cf1367612aa0 100644 --- a/interfaces/kits/js/src/mod_fs/properties/movedir_core.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/movedir_core.cpp @@ -226,10 +226,6 @@ static int MoveDirFunc(const string &src, const string &dest, const int mode, de if (found == std::string::npos) { return EINVAL; } - if (access(src.c_str(), W_OK) != 0) { - HILOGE("Failed to move src directory due to doesn't exist or hasn't write permission"); - return errno; - } string dirName = string(src).substr(found); string destStr = dest + dirName; auto [destStrExist, destStrEmpty] = JudgeExistAndEmpty(destStr); diff --git a/interfaces/test/unittest/js/BUILD.gn b/interfaces/test/unittest/js/BUILD.gn index 8d578dcc524a2110b5a7d4f921a3b71e37b254a7..b798a94947fa91641bdebc8150747cff9a99115b 100644 --- a/interfaces/test/unittest/js/BUILD.gn +++ b/interfaces/test/unittest/js/BUILD.gn @@ -189,9 +189,11 @@ ohos_unittest("ani_file_fs_mock_test") { "mod_fs/properties/stat_core_mock_test.cpp", "mod_fs/properties/symlink_core_mock_test.cpp", "mod_fs/properties/trans_listener_mock_test.cpp", + "mod_fs/properties/truncate_core_mock_test.cpp", "mod_fs/properties/unlink_core_mock_test.cpp", "mod_fs/properties/utimes_core_mock_test.cpp", "mod_fs/properties/watcher_core_mock_test.cpp", + "mod_fs/properties/write_core_mock_test.cpp", "mod_fs/properties/xattr_core_mock_test.cpp", ] diff --git a/interfaces/test/unittest/js/mod_fs/properties/move_core_mock_test.cpp b/interfaces/test/unittest/js/mod_fs/properties/move_core_mock_test.cpp index 175fd3ab1324a9614761f3d8b7d78da053a84c01..9cb96467e210d24e7b92298b8e1b87daa870e815 100644 --- a/interfaces/test/unittest/js/mod_fs/properties/move_core_mock_test.cpp +++ b/interfaces/test/unittest/js/mod_fs/properties/move_core_mock_test.cpp @@ -77,7 +77,6 @@ HWTEST_F(MoveCoreMockTest, MoveCoreMockTest_DoMove_000, testing::ext::TestSize.L std::string src; std::string dest; - EXPECT_CALL(*uvMock, uv_fs_access(_, _, _, _, _)).WillOnce(Return(0)); EXPECT_CALL(*uvMock, uv_fs_rename(_, _, _, _, _)).WillOnce(Return(0)); auto res = MoveCore::DoMove(src, dest); @@ -100,7 +99,6 @@ HWTEST_F(MoveCoreMockTest, MoveCoreMockTest_DoMove_001, testing::ext::TestSize.L std::string src; std::string dest; - EXPECT_CALL(*uvMock, uv_fs_access(_, _, _, _, _)).WillOnce(Return(0)); EXPECT_CALL(*uvMock, uv_fs_rename(_, _, _, _, _)).WillOnce(Return(-1)); auto res = MoveCore::DoMove(src, dest); @@ -124,7 +122,6 @@ HWTEST_F(MoveCoreMockTest, MoveCoreMockTest_DoMove_002, testing::ext::TestSize.L std::string dest; optional mode = std::make_optional(MODE_FORCE_MOVE); - EXPECT_CALL(*uvMock, uv_fs_access(_, _, _, _, _)).WillOnce(Return(0)); EXPECT_CALL(*uvMock, uv_fs_rename(_, _, _, _, _)).WillOnce(Return(-1)); auto res = MoveCore::DoMove(src, dest, mode); @@ -132,28 +129,6 @@ HWTEST_F(MoveCoreMockTest, MoveCoreMockTest_DoMove_002, testing::ext::TestSize.L GTEST_LOG_(INFO) << "MoveCoreMockTest-end MoveCoreMockTest_DoMove_002"; } -/** - * @tc.name: MoveCoreMockTest_DoMove_003 - * @tc.desc: Test function of MoveCore::DoMove interface for FALSE. - * @tc.size: MEDIUM - * @tc.type: FUNC - * @tc.level Level 1 - */ -HWTEST_F(MoveCoreMockTest, MoveCoreMockTest_DoMove_003, testing::ext::TestSize.Level1) -{ - GTEST_LOG_(INFO) << "MoveCoreMockTest-begin MoveCoreMockTest_DoMove_003"; - - std::string src; - std::string dest; - - EXPECT_CALL(*uvMock, uv_fs_access(_, _, _, _, _)).WillOnce(Return(-1)); - - auto res = MoveCore::DoMove(src, dest); - EXPECT_EQ(res.IsSuccess(), false); - - GTEST_LOG_(INFO) << "MoveCoreMockTest-end MoveCoreMockTest_DoMove_003"; -} - /** * @tc.name: MoveCoreMockTest_DoMove_004 * @tc.desc: Test function of MoveCore::DoMove interface for FALSE. @@ -169,7 +144,7 @@ HWTEST_F(MoveCoreMockTest, MoveCoreMockTest_DoMove_004, testing::ext::TestSize.L std::string dest; optional mode = std::make_optional(MODE_THROW_ERR); - EXPECT_CALL(*uvMock, uv_fs_access(_, _, _, _, _)).WillOnce(Return(1)).WillOnce(Return(0)); + EXPECT_CALL(*uvMock, uv_fs_access(_, _, _, _, _)).WillOnce(Return(0)); auto res = MoveCore::DoMove(src, dest, mode); EXPECT_EQ(res.IsSuccess(), false); @@ -192,7 +167,7 @@ HWTEST_F(MoveCoreMockTest, MoveCoreMockTest_DoMove_005, testing::ext::TestSize.L std::string dest; optional mode = std::make_optional(MODE_THROW_ERR); - EXPECT_CALL(*uvMock, uv_fs_access(_, _, _, _, _)).WillOnce(Return(1)).WillOnce(Return(-1)); + EXPECT_CALL(*uvMock, uv_fs_access(_, _, _, _, _)).WillOnce(Return(-1)); auto res = MoveCore::DoMove(src, dest, mode); EXPECT_EQ(res.IsSuccess(), false); @@ -215,7 +190,6 @@ HWTEST_F(MoveCoreMockTest, MoveCoreMockTest_DoMove_006, testing::ext::TestSize.L std::string dest; optional mode = std::make_optional(MODE_FORCE_MOVE); - EXPECT_CALL(*uvMock, uv_fs_access(_, _, _, _, _)).WillOnce(Return(1)); EXPECT_CALL(*uvMock, uv_fs_rename(_, _, _, _, _)).WillOnce(Return(-1)); auto res = MoveCore::DoMove(src, dest, mode); @@ -239,7 +213,6 @@ HWTEST_F(MoveCoreMockTest, MoveCoreMockTest_DoMove_007, testing::ext::TestSize.L std::string dest; optional mode = std::make_optional(MODE_FORCE_MOVE); - EXPECT_CALL(*uvMock, uv_fs_access(_, _, _, _, _)).WillOnce(Return(1)); EXPECT_CALL(*uvMock, uv_fs_rename(_, _, _, _, _)).WillOnce(Return(1)); auto res = MoveCore::DoMove(src, dest, mode); @@ -262,7 +235,6 @@ HWTEST_F(MoveCoreMockTest, MoveCoreMockTest_DoMove_008, testing::ext::TestSize.L std::string src; std::string dest; - EXPECT_CALL(*uvMock, uv_fs_access(_, _, _, _, _)).WillOnce(Return(0)); EXPECT_CALL(*uvMock, uv_fs_rename(_, _, _, _, _)).WillOnce(Return(1)); auto res = MoveCore::DoMove(src, dest); @@ -286,7 +258,6 @@ HWTEST_F(MoveCoreMockTest, MoveCoreMockTest_DoMove_009, testing::ext::TestSize.L std::string dest; optional mode = std::make_optional(MODE_FORCE_MOVE); - EXPECT_CALL(*uvMock, uv_fs_access(_, _, _, _, _)).WillOnce(Return(1)); EXPECT_CALL(*uvMock, uv_fs_rename(_, _, _, _, _)).WillOnce(Return(-1)); EXPECT_CALL(*uvMock, uv_fs_stat(_, _, _, _)).WillOnce(Return(-1)); @@ -314,7 +285,6 @@ HWTEST_F(MoveCoreMockTest, MoveCoreMockTest_DoMove_0010, testing::ext::TestSize. int fd = open(dest.c_str(), O_RDWR | O_CREAT, 0666); ASSERT_NE(fd, -1); - EXPECT_CALL(*uvMock, uv_fs_access(_, _, _, _, _)).WillOnce(Return(1)); EXPECT_CALL(*uvMock, uv_fs_rename(_, _, _, _, _)).WillOnce(Return(-1)); EXPECT_CALL(*uvMock, uv_fs_stat(_, _, _, _)).WillOnce(Return(1)); @@ -340,7 +310,6 @@ HWTEST_F(MoveCoreMockTest, MoveCoreMockTest_DoMove_0011, testing::ext::TestSize. std::string dest; optional mode = std::make_optional(MODE_FORCE_MOVE); - EXPECT_CALL(*uvMock, uv_fs_access(_, _, _, _, _)).WillOnce(Return(1)); EXPECT_CALL(*uvMock, uv_fs_rename(_, _, _, _, _)).WillOnce(Return(-1)); EXPECT_CALL(*uvMock, uv_fs_stat(_, _, _, _)).WillOnce(Return(1)); @@ -368,7 +337,6 @@ HWTEST_F(MoveCoreMockTest, MoveCoreMockTest_DoMove_0012, testing::ext::TestSize. int fd = open(src.c_str(), O_RDWR | O_CREAT, 0666); ASSERT_NE(fd, -1); - EXPECT_CALL(*uvMock, uv_fs_access(_, _, _, _, _)).WillOnce(Return(1)); EXPECT_CALL(*uvMock, uv_fs_rename(_, _, _, _, _)).WillOnce(Return(-1)); EXPECT_CALL(*uvMock, uv_fs_stat(_, _, _, _)).WillOnce(Return(1)); EXPECT_CALL(*uvMock, uv_fs_unlink(_, _, _, _)).WillOnce(Return(-1)).WillOnce(Return(-1)); @@ -400,7 +368,6 @@ HWTEST_F(MoveCoreMockTest, MoveCoreMockTest_DoMove_0013, testing::ext::TestSize. int fd = open(src.c_str(), O_RDWR | O_CREAT, 0666); ASSERT_NE(fd, -1); - EXPECT_CALL(*uvMock, uv_fs_access(_, _, _, _, _)).WillOnce(Return(1)); EXPECT_CALL(*uvMock, uv_fs_rename(_, _, _, _, _)).WillOnce(Return(-1)); EXPECT_CALL(*uvMock, uv_fs_stat(_, _, _, _)).WillOnce(Return(1)); EXPECT_CALL(*uvMock, uv_fs_unlink(_, _, _, _)).WillOnce(Return(-1)).WillOnce(Return(1)); @@ -432,7 +399,6 @@ HWTEST_F(MoveCoreMockTest, MoveCoreMockTest_DoMove_0014, testing::ext::TestSize. int fd = open(src.c_str(), O_RDWR | O_CREAT, 0666); ASSERT_NE(fd, -1); - EXPECT_CALL(*uvMock, uv_fs_access(_, _, _, _, _)).WillOnce(Return(1)); EXPECT_CALL(*uvMock, uv_fs_rename(_, _, _, _, _)).WillOnce(Return(-1)); EXPECT_CALL(*uvMock, uv_fs_stat(_, _, _, _)).WillOnce(Return(1)); EXPECT_CALL(*uvMock, uv_fs_unlink(_, _, _, _)).WillOnce(Return(1)); diff --git a/interfaces/test/unittest/js/mod_fs/properties/truncate_core_mock_test.cpp b/interfaces/test/unittest/js/mod_fs/properties/truncate_core_mock_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a8e459014b266b582a592deb6285028e2067833c --- /dev/null +++ b/interfaces/test/unittest/js/mod_fs/properties/truncate_core_mock_test.cpp @@ -0,0 +1,169 @@ +/* + * Copyright (C) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "truncate_core.h" +#include "uv_fs_mock.h" + +#include + +namespace OHOS::FileManagement::ModuleFileIO::Test { +using namespace testing; +using namespace testing::ext; +using namespace std; + +class TruncateCoreMockTest : public testing::Test { +public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); + static inline shared_ptr uvMock = nullptr; +}; + +void TruncateCoreMockTest::SetUpTestCase(void) +{ + GTEST_LOG_(INFO) << "SetUpTestCase"; + uvMock = std::make_shared(); + Uvfs::ins = uvMock; +} + +void TruncateCoreMockTest::TearDownTestCase(void) +{ + GTEST_LOG_(INFO) << "TearDownTestCase"; + Uvfs::ins = nullptr; + uvMock = nullptr; +} + +void TruncateCoreMockTest::SetUp(void) +{ + GTEST_LOG_(INFO) << "SetUp"; +} + +void TruncateCoreMockTest::TearDown(void) +{ + GTEST_LOG_(INFO) << "TearDown"; +} + +/** + * @tc.name: TruncateCoreMockTest_DoTruncate_001 + * @tc.desc: Test function of RmdirCore::DoTruncate interface for Failed. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(TruncateCoreMockTest, TruncateCoreMockTest_DoTruncate_001, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TruncateCoreMockTest-begin TruncateCoreMockTest_DoTruncate_001"; + + FileInfo fileInfo; + fileInfo.isPath = true; + fileInfo.fdg = std::make_unique(1); + + EXPECT_CALL(*uvMock, uv_fs_open(_, _, _, _, _, _)).WillOnce(Return(-1)); + auto res = TruncateCore::DoTruncate(fileInfo); + EXPECT_EQ(res.IsSuccess(), false); + + GTEST_LOG_(INFO) << "TruncateCoreMockTest-end TruncateCoreMockTest_DoTruncate_001"; +} + +/** + * @tc.name: TruncateCoreMockTest_DoTruncate_002 + * @tc.desc: Test function of RmdirCore::DoTruncate interface for Failed. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(TruncateCoreMockTest, TruncateCoreMockTest_DoTruncate_002, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TruncateCoreMockTest-begin TruncateCoreMockTest_DoTruncate_002"; + + FileInfo fileInfo; + fileInfo.isPath = true; + fileInfo.fdg = std::make_unique(1); + + EXPECT_CALL(*uvMock, uv_fs_open(_, _, _, _, _, _)).WillOnce(Return(1)); + EXPECT_CALL(*uvMock, uv_fs_ftruncate(_, _, _, _, _)).WillOnce(Return(-1)); + auto res = TruncateCore::DoTruncate(fileInfo); + EXPECT_EQ(res.IsSuccess(), false); + + GTEST_LOG_(INFO) << "TruncateCoreMockTest-end TruncateCoreMockTest_DoTruncate_002"; +} + +/** + * @tc.name: TruncateCoreMockTest_DoTruncate_003 + * @tc.desc: Test function of RmdirCore::DoTruncate interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(TruncateCoreMockTest, TruncateCoreMockTest_DoTruncate_003, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TruncateCoreMockTest-begin TruncateCoreMockTest_DoTruncate_003"; + + FileInfo fileInfo; + fileInfo.isPath = true; + fileInfo.fdg = std::make_unique(1); + + EXPECT_CALL(*uvMock, uv_fs_open(_, _, _, _, _, _)).WillOnce(Return(1)); + EXPECT_CALL(*uvMock, uv_fs_ftruncate(_, _, _, _, _)).WillOnce(Return(1)); + auto res = TruncateCore::DoTruncate(fileInfo); + EXPECT_EQ(res.IsSuccess(), true); + + GTEST_LOG_(INFO) << "TruncateCoreMockTest-end TruncateCoreMockTest_DoTruncate_003"; +} + +/** + * @tc.name: TruncateCoreMockTest_DoTruncate_004 + * @tc.desc: Test function of RmdirCore::DoTruncate interface for FALSE. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(TruncateCoreMockTest, TruncateCoreMockTest_DoTruncate_004, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TruncateCoreMockTest-begin TruncateCoreMockTest_DoTruncate_004"; + + FileInfo fileInfo; + fileInfo.fdg = std::make_unique(1); + + EXPECT_CALL(*uvMock, uv_fs_ftruncate(_, _, _, _, _)).WillOnce(Return(-1)); + auto res = TruncateCore::DoTruncate(fileInfo); + EXPECT_EQ(res.IsSuccess(), false); + + GTEST_LOG_(INFO) << "TruncateCoreMockTest-end TruncateCoreMockTest_DoTruncate_004"; +} + +/** + * @tc.name: TruncateCoreMockTest_DoTruncate_005 + * @tc.desc: Test function of RmdirCore::DoTruncate interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(TruncateCoreMockTest, TruncateCoreMockTest_DoTruncate_005, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "TruncateCoreMockTest-begin TruncateCoreMockTest_DoTruncate_005"; + + FileInfo fileInfo; + fileInfo.fdg = std::make_unique(1); + + EXPECT_CALL(*uvMock, uv_fs_ftruncate(_, _, _, _, _)).WillOnce(Return(1)); + auto res = TruncateCore::DoTruncate(fileInfo); + EXPECT_EQ(res.IsSuccess(), true); + + GTEST_LOG_(INFO) << "TruncateCoreMockTest-end TruncateCoreMockTest_DoTruncate_005"; +} + +} // namespace OHOS::FileManagement::ModuleFileIO::Test \ No newline at end of file diff --git a/interfaces/test/unittest/js/mod_fs/properties/write_core_mock_test.cpp b/interfaces/test/unittest/js/mod_fs/properties/write_core_mock_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..406aa26746912dcf4cfee18a942796a055157d0e --- /dev/null +++ b/interfaces/test/unittest/js/mod_fs/properties/write_core_mock_test.cpp @@ -0,0 +1,122 @@ +/* + * Copyright (C) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "write_core.h" +#include "uv_fs_mock.h" + +#include + +namespace OHOS::FileManagement::ModuleFileIO::Test { +using namespace testing; +using namespace testing::ext; +using namespace std; + +class WriteCoreMockTest : public testing::Test { +public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); + static inline shared_ptr uvMock = nullptr; +}; + +void WriteCoreMockTest::SetUpTestCase(void) +{ + GTEST_LOG_(INFO) << "SetUpTestCase"; + uvMock = std::make_shared(); + Uvfs::ins = uvMock; +} + +void WriteCoreMockTest::TearDownTestCase(void) +{ + GTEST_LOG_(INFO) << "TearDownTestCase"; + Uvfs::ins = nullptr; + uvMock = nullptr; +} + +void WriteCoreMockTest::SetUp(void) +{ + GTEST_LOG_(INFO) << "SetUp"; +} + +void WriteCoreMockTest::TearDown(void) +{ + GTEST_LOG_(INFO) << "TearDown"; +} + +/** + * @tc.name: WriteCoreMockTest_DoWrite1_001 + * @tc.desc: Test function of WriteCore::DoWrite3 interface for FALSE. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(WriteCoreMockTest, WriteCoreMockTest_DoWrite1_001, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "WriteCoreMockTest-begin WriteCoreMockTest_DoWrite1_001"; + + int32_t fd = 1; + string buffer; + + EXPECT_CALL(*uvMock, uv_fs_write(_, _, _, _, _, _, _)).WillOnce(Return(-1)); + auto res = WriteCore::DoWrite(fd, buffer); + EXPECT_EQ(res.IsSuccess(), false); + + GTEST_LOG_(INFO) << "WriteCoreMockTest-end WriteCoreMockTest_DoWrite1_001"; +} + +/** + * @tc.name: WriteCoreMockTest_DoWrite1_002 + * @tc.desc: Test function of WriteCore::DoWrite3 interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(WriteCoreMockTest, WriteCoreMockTest_DoWrite1_002, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "WriteCoreMockTest-begin WriteCoreMockTest_DoWrite1_002"; + + int32_t fd = 1; + string buffer; + + EXPECT_CALL(*uvMock, uv_fs_write(_, _, _, _, _, _, _)).WillOnce(Return(1)); + auto res = WriteCore::DoWrite(fd, buffer); + EXPECT_EQ(res.IsSuccess(), true); + + GTEST_LOG_(INFO) << "WriteCoreMockTest-end WriteCoreMockTest_DoWrite1_002"; +} + +/** + * @tc.name: WriteCoreMockTest_DoWrite2_003 + * @tc.desc: Test function of WriteCore::DoWrite2 interface for FALSE. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(WriteCoreMockTest, WriteCoreMockTest_DoWrite2_003, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "WriteCoreMockTest-begin WriteCoreMockTest_DoWrite2_003"; + + int32_t fd = -1; + string buffer; + + EXPECT_CALL(*uvMock, uv_fs_write(_, _, _, _, _, _, _)).WillOnce(Return(-1)); + auto res = WriteCore::DoWrite(fd, buffer); + EXPECT_EQ(res.IsSuccess(), false); + + GTEST_LOG_(INFO) << "WriteCoreMockTest-end WriteCoreMockTest_DoWrite2_003"; +} + +} // namespace OHOS::FileManagement::ModuleFileIO::Test \ No newline at end of file