Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: test/FileSystemJsObject.cpp

Issue 29823572: Noissue - add unit-test to check that renameFile works as expected by FilterStorage.js (Closed) Base URL: https://github.com/adblockplus/libadblockplus@d361cdf75c6c5af2aaa9b484092ded6c0a1dc441
Patch Set: Created July 5, 2018, 10:06 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/FileSystemJsObject.cpp
diff --git a/test/FileSystemJsObject.cpp b/test/FileSystemJsObject.cpp
index 96c07cadc8184a16e000369290ac3e162af7034f..051febde8770e490c543ce58249d8e98d0b0f54c 100644
--- a/test/FileSystemJsObject.cpp
+++ b/test/FileSystemJsObject.cpp
@@ -21,6 +21,8 @@
using namespace AdblockPlus;
+extern std::string jsSources[];
+
namespace
{
class MockFileSystem : public AdblockPlus::IFileSystem
@@ -398,4 +400,27 @@ _fileSystem.readFromFile("foo",
)js");
EXPECT_EQ(2u, readLines.size());
EXPECT_EQ("Error: my-error at undefined:8", error);
-}
+}
+
+TEST_F(FileSystemJsObjectTest, MoveNonExistingFile)
+{
+ mockFileSystem->success = false;
+ auto& jsEngine = GetJsEngine();
+ const std::vector<std::string> jsFiles = {"compat.js", "io.js"};
+ for (int i = 0; !jsSources[i].empty(); i += 2)
+ {
+ if (jsFiles.end() != std::find(jsFiles.begin(), jsFiles.end(), jsSources[i]))
+ {
+ jsEngine.Evaluate(jsSources[i + 1], jsSources[i]);
+ }
+ }
+ jsEngine.Evaluate(R"js(
+ let hasError = false;
+ let isNextHandlerCalled = false;
+ require("io").IO.renameFile("foo", "bar")
+ .catch((e) => {hasError = e})
+ .then(() => isNextHandlerCalled = true);
+ )js");
+ EXPECT_EQ("Unable to move foo to bar", jsEngine.Evaluate("hasError").AsString());
+ EXPECT_TRUE(jsEngine.Evaluate("isNextHandlerCalled").AsBool());
+}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld