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 "origin": "dcs-host:/path/to/somefile.fits",
39 "path": "dcs/somefile.fits"
63 EXPECT_EQ(m_root, ws.
GetPath());
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"));
141 EXPECT_EQ(spec.id,
"TEST.ID");
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());