diff --git a/test/uvw/fs_event.cpp b/test/uvw/fs_event.cpp index 637ca692..42cc4029 100644 --- a/test/uvw/fs_event.cpp +++ b/test/uvw/fs_event.cpp @@ -2,32 +2,36 @@ #include -TEST(FsEvent, StartAndStop) { - const std::string dirname = std::string{TARGET_FS_EVENT_DIR}; +TEST(FsEvent, Functionalities) { + const std::string relative = std::string{"test.file"}; + const std::string absolute = std::string{TARGET_FS_EVENT_DIR} + "/" + relative; + const std::string rename = std::string{TARGET_FS_EVENT_DIR} + std::string{"/test.rename"}; auto loop = uvw::Loop::getDefault(); auto handle = loop->resource(); - auto req = loop->resource(); + auto fileReq = loop->resource(); + auto fsReq = loop->resource(); bool checkFsEventEvent = false; - req->mkdirSync(dirname, 0755); - handle->on([](const auto &, auto &) { FAIL(); }); - req->on([](const auto &, auto &) { FAIL(); }); + fileReq->on([](const auto &, auto &) { FAIL(); }); + fsReq->on([](const auto &, auto &) { FAIL(); }); - handle->on([&checkFsEventEvent, &dirname](const auto &, auto &hndl) { + handle->on([&checkFsEventEvent, &relative](const auto &event, auto &hndl) { ASSERT_FALSE(checkFsEventEvent); + ASSERT_EQ(std::string{event.filename}, relative); checkFsEventEvent = true; hndl.stop(); hndl.close(); ASSERT_TRUE(hndl.closing()); }); - req->rmdir(dirname); - handle->start(dirname); + fileReq->openSync(absolute, O_CREAT | O_RDWR | O_TRUNC, 0644); + fsReq->rename(absolute, rename); + handle->start(absolute); - ASSERT_EQ(handle->path(), dirname); + ASSERT_EQ(handle->path(), absolute); ASSERT_TRUE(handle->active()); ASSERT_FALSE(handle->closing());