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"));
77 ASSERT_FALSE(fs::exists(m_root /
"in-progress"));
78 ASSERT_FALSE(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());
110 daq_ws->StoreStatus(status);
112 auto daq_ws_root = m_root /
"archive" /
"DAQ";
113 EXPECT_TRUE(fs::exists(daq_ws_root)) <<
"Path: " << daq_ws_root;
114 EXPECT_TRUE(fs::exists(daq_ws_root /
"status.json"));
115 EXPECT_FALSE(fs::exists(m_root /
"in-progress" /
"DAQ"));
125 daq_ws->StoreStatus(status);
127 auto daq_ws_root = m_root /
"archive" /
"DAQ";
128 EXPECT_TRUE(fs::exists(daq_ws_root)) <<
"Path: " << daq_ws_root;
129 EXPECT_TRUE(fs::exists(daq_ws_root /
"status.json"));
130 EXPECT_FALSE(fs::exists(m_root /
"in-progress" /
"DAQ"));
137 throw std::runtime_error(r.
Str());
146 EXPECT_FALSE(fs::exists(m_root /
"in-progress" /
"DAQ"));
147 EXPECT_FALSE(fs::exists(m_root /
"archive" /
"DAQ"));
150 throw std::runtime_error(r.
Str());
157 EXPECT_FALSE(fs::exists(m_root /
"specification.json"));
159 EXPECT_TRUE(fs::exists(m_root /
"specification.json"));
165 throw std::runtime_error(r.
Str());
172 EXPECT_FALSE(fs::exists(m_root /
"status.json"));
174 store_status.
id =
"DAQ";
177 EXPECT_TRUE(fs::exists(m_root /
"status.json"));
181 throw std::runtime_error(r.
Str());
188 EXPECT_FALSE(fs::exists(m_root /
"sources.json"));
191 EXPECT_TRUE(fs::exists(m_root /
"sources.json"));
195 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 LoadArchivedStatus(std::string const &daq_id) const -> std::optional< Status > override
Loads a previously initialized DAQ 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")
ASSERT_TRUE(std::holds_alternative< OlasReceiver >(spec.receivers[0]))
TEST_F(WorkspaceTest, GetPath)