13 #include <gtest/gtest.h>
18 namespace fs = std::filesystem;
25 std::string tpl(
"daqLibdpmTest-workspace-XXXXXX");
27 m_root = fs::current_path() / tpl;
29 ASSERT_FALSE(
m_root.empty());
35 "fileId": "TEST.FILEID",
38 "location": "dcs-host:/path/to/somefile.fits",
39 "path": "dcs/somefile.fits"
67 ASSERT_FALSE(fs::exists(m_root /
"in-progress"));
68 ASSERT_FALSE(fs::exists(m_root /
"archive"));
71 ASSERT_TRUE(fs::exists(m_root /
"in-progress"));
72 ASSERT_TRUE(fs::exists(m_root /
"archive"));
77 ASSERT_FALSE(fs::exists(m_root /
"in-progress"));
78 ASSERT_FALSE(fs::exists(m_root /
"archive"));
81 ASSERT_TRUE(fs::exists(m_root /
"in-progress"));
82 ASSERT_TRUE(fs::exists(m_root /
"archive"));
87 std::ofstream(m_root).put(
'z');
95 auto daq_ws_root = m_root /
"in-progress" /
"DAQ";
96 EXPECT_EQ(daq_ws->GetPath(), daq_ws_root);
97 EXPECT_TRUE(fs::exists(daq_ws_root)) <<
"Path: " << daq_ws_root;
100 throw std::runtime_error(r.
Str());
108 daq_ws->StoreStatus({});
110 auto daq_ws_root = m_root /
"archive" /
"DAQ";
111 EXPECT_TRUE(fs::exists(daq_ws_root)) <<
"Path: " << daq_ws_root;
112 EXPECT_TRUE(fs::exists(daq_ws_root /
"status.json"));
113 EXPECT_FALSE(fs::exists(m_root /
"in-progress" /
"DAQ"));
116 throw std::runtime_error(r.
Str());
125 EXPECT_FALSE(fs::exists(m_root /
"in-progress" /
"DAQ"));
126 EXPECT_FALSE(fs::exists(m_root /
"archive" /
"DAQ"));
129 throw std::runtime_error(r.
Str());
136 EXPECT_FALSE(fs::exists(m_root /
"specification.json"));
138 EXPECT_TRUE(fs::exists(m_root /
"specification.json"));
144 throw std::runtime_error(r.
Str());
151 EXPECT_FALSE(fs::exists(m_root /
"status.json"));
153 store_status.
id =
"DAQ";
156 EXPECT_TRUE(fs::exists(m_root /
"status.json"));
160 throw std::runtime_error(r.
Str());
167 EXPECT_FALSE(fs::exists(m_root /
"sources.json"));
170 EXPECT_TRUE(fs::exists(m_root /
"sources.json"));
174 throw std::runtime_error(r.
Str());
void StoreSpecification(std::string const &specification) const override
Get file name of the data product specification stored in StoreSpecification()
void StoreSourceLookup(SourceResolver::Mapping const &status) const override
auto LoadSpecification() const -> json::DpSpec override
Get file name of the data product specification stored in StoreSpecification()
void StoreStatus(Status const &status) const override
auto LoadSourceLookup() const -> SourceResolver::Mapping override
auto LoadStatus() const -> Status override
std::map< SourceFile, std::string > Mapping
Implementation of daq::dpm::Workspace.
auto InitializeDaq(std::string const &daq_id) -> std::unique_ptr< DaqWorkspace > override
Initializes new DAQ Workspace.
void RemoveDaq(std::string const &daq_id) override
Removes workspace and all containing files for DAQ without archiving it.
auto GetPath() const -> std::filesystem::path override
auto ArchiveDaq(std::string const &daq_id) -> std::filesystem::path override
Archives specified DAQ witout deleting any files, typically by moving it to a specific location in th...
Adapter object intended to be used in contexts without direct access to the output-stream object.
std::string Str() const
Convenience function for constructing a std::string from the exception.
daq::dpm::Workspace interface and implementation declaration
daq::json::TestParseStartDaqV2Spec _json
@ Merging
DAQ is being merged.
Non observable status object that keeps stores status of data acquisition.
EXPECT_EQ(meta.rr_uri, "zpb.rr://meta")
TEST_F(WorkspaceTest, GetPath)