Skip to content

Commit 6521c26

Browse files
committed
added unit test for query that was failing from client
1 parent 8a8fe09 commit 6521c26

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/rsession-t.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,27 @@ namespace testing {
3737
ASSERT_TRUE(results1["string"] == "[1] 4\n");
3838
}
3939

40+
TEST_F(SessionTest, basicScriptWithQueryIdAndStartTime)
41+
{
42+
//need to delay action until after startEventLoop()
43+
std::thread t([]() {
44+
std::this_thread::sleep_for(std::chrono::milliseconds(1));
45+
session->doJson("{\"msg\":\"execScript\", \"argument\":\"rnorm(20)\", \"queryId\":3, \"startTime\": \"1502817203955\"}");
46+
});
47+
t.detach();
48+
session->startCountdown(2);
49+
session->startEventLoop();
50+
ASSERT_EQ(session->_messages.size(), 2);
51+
json results1 = session->popMessage();
52+
ASSERT_TRUE(results1["msg"] == "results");
53+
string results = results1["string"];
54+
string prefix = " [1] ";
55+
ASSERT_TRUE(std::equal(prefix.begin(), prefix.end(), results.begin()));
56+
int queryId = results1["queryId"];
57+
ASSERT_TRUE(queryId == 3);
58+
}
59+
60+
4061
TEST_F(SessionTest, execFiles)
4162
{
4263
session->copyFileToWorkingDirectory("test1.R");

0 commit comments

Comments
 (0)