diff --git a/services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest.java b/services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest.java index 4a3ba7d2cf..d02c337b98 100644 --- a/services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest.java +++ b/services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest.java @@ -55,6 +55,10 @@ public class WLGitBridgeIntegrationTest { put("base", new SnapshotAPIStateBuilder(getResourceAsStream("/canPullADeletedBinaryFile/base/state.json")).build()); put("withModifiedNestedFile", new SnapshotAPIStateBuilder(getResourceAsStream("/canPullAModifiedNestedFile/withModifiedNestedFile/state.json")).build()); }}); + put("canPullDeletedNestedFiles", new HashMap() {{ + put("base", new SnapshotAPIStateBuilder(getResourceAsStream("/canPullDeletedNestedFiles/base/state.json")).build()); + put("withDeletedNestedFiles", new SnapshotAPIStateBuilder(getResourceAsStream("/canPullDeletedNestedFiles/withDeletedNestedFiles/state.json")).build()); + }}); put("cannotCloneAProtectedProject", new HashMap() {{ put("state", new SnapshotAPIStateBuilder(getResourceAsStream("/cannotCloneAProtectedProject/state/state.json")).build()); }}); @@ -219,6 +223,29 @@ public class WLGitBridgeIntegrationTest { assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/canPullAModifiedNestedFile/withModifiedNestedFile/testproj"), testprojDir.toPath())); } + @Test + public void canPullDeletedNestedFiles() throws IOException, GitAPIException, InterruptedException { + MockSnapshotServer server = new MockSnapshotServer(3865, getResource("/canPullDeletedNestedFiles").toFile()); + server.start(); + server.setState(states.get("canPullDeletedNestedFiles").get("base")); + GitBridgeApp wlgb = new GitBridgeApp(new String[] { + makeConfigFile(33865, 3865) + }); + wlgb.run(); + File dir = folder.newFolder(); + Process gitBase = runtime.exec("git clone http://127.0.0.1:33865/testproj.git", null, dir); + int exitCodeBase = gitBase.waitFor(); + File testprojDir = new File(dir, "testproj"); + assertEquals(0, exitCodeBase); + assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/canPullDeletedNestedFiles/base/testproj"), testprojDir.toPath())); + server.setState(states.get("canPullDeletedNestedFiles").get("withDeletedNestedFiles")); + Process gitWithDeletedBinaryFile = runtime.exec("git pull", null, testprojDir); + int exitCodeWithDeletedBinaryFile = gitWithDeletedBinaryFile.waitFor(); + wlgb.stop(); + assertEquals(0, exitCodeWithDeletedBinaryFile); + assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/canPullDeletedNestedFiles/withDeletedNestedFiles/testproj"), testprojDir.toPath())); + } + private static final String EXPECTED_OUT_PROTECTED = "Cloning into 'protected'...\n" + diff --git a/services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/canPullDeletedNestedFiles/base/state.json b/services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/canPullDeletedNestedFiles/base/state.json new file mode 100644 index 0000000000..d972e58345 --- /dev/null +++ b/services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/canPullDeletedNestedFiles/base/state.json @@ -0,0 +1,54 @@ +[ + { + "project": "testproj", + "getDoc": { + "versionID": 1, + "createdAt": "2014-11-30T18:40:58.123Z", + "email": "jdleesmiller+1@gmail.com", + "name": "John+1" + }, + "getSavedVers": [ + { + "versionID": 1, + "comment": "added more info on doc GET and error details", + "email": "jdleesmiller+1@gmail.com", + "name": "John+1", + "createdAt": "2014-11-30T18:47:01.456Z" + } + ], + "getForVers": [ + { + "versionID": 1, + "srcs": [ + { + "content": "content\n", + "path": "main.tex" + }, + { + "content": "This text is from another file.", + "path": "test.tex" + }, + { + "content": "nest1", + "path": "nest1/nest1.tex" + }, + { + "content": "nest2", + "path": "nest1/nest2/nest2.tex" + } + ], + "atts": [ + { + "url": "http://127.0.0.1:3865/base/testproj/overleaf-white-410.png", + "path": "overleaf-white-410.png" + } + ] + } + ], + "push": "success", + "postback": { + "type": "success", + "versionID": 2 + } + } +] \ No newline at end of file diff --git a/services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/canPullDeletedNestedFiles/base/testproj/main.tex b/services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/canPullDeletedNestedFiles/base/testproj/main.tex new file mode 100644 index 0000000000..d95f3ad14d --- /dev/null +++ b/services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/canPullDeletedNestedFiles/base/testproj/main.tex @@ -0,0 +1 @@ +content diff --git a/services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/canPullDeletedNestedFiles/base/testproj/nest1/nest1.tex b/services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/canPullDeletedNestedFiles/base/testproj/nest1/nest1.tex new file mode 100644 index 0000000000..487d7bb966 --- /dev/null +++ b/services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/canPullDeletedNestedFiles/base/testproj/nest1/nest1.tex @@ -0,0 +1 @@ +nest1 \ No newline at end of file diff --git a/services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/canPullDeletedNestedFiles/base/testproj/nest1/nest2/nest2.tex b/services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/canPullDeletedNestedFiles/base/testproj/nest1/nest2/nest2.tex new file mode 100644 index 0000000000..e3333784c2 --- /dev/null +++ b/services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/canPullDeletedNestedFiles/base/testproj/nest1/nest2/nest2.tex @@ -0,0 +1 @@ +nest2 \ No newline at end of file diff --git a/services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/canPullDeletedNestedFiles/base/testproj/overleaf-white-410.png b/services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/canPullDeletedNestedFiles/base/testproj/overleaf-white-410.png new file mode 100644 index 0000000000..6a23d10c15 Binary files /dev/null and b/services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/canPullDeletedNestedFiles/base/testproj/overleaf-white-410.png differ diff --git a/services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/canPullDeletedNestedFiles/base/testproj/test.tex b/services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/canPullDeletedNestedFiles/base/testproj/test.tex new file mode 100644 index 0000000000..046794f19a --- /dev/null +++ b/services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/canPullDeletedNestedFiles/base/testproj/test.tex @@ -0,0 +1 @@ +This text is from another file. \ No newline at end of file diff --git a/services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/canPullDeletedNestedFiles/withDeletedNestedFiles/state.json b/services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/canPullDeletedNestedFiles/withDeletedNestedFiles/state.json new file mode 100644 index 0000000000..683f1778f6 --- /dev/null +++ b/services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/canPullDeletedNestedFiles/withDeletedNestedFiles/state.json @@ -0,0 +1,80 @@ +[ + { + "project": "testproj", + "getDoc": { + "versionID": 2, + "createdAt": "2014-11-30T18:40:58.123Z", + "email": "jdleesmiller+1@gmail.com", + "name": "John+1" + }, + "getSavedVers": [ + { + "versionID": 2, + "comment": "i deleted nested stuff", + "email": "jdleesmiller+1@gmail.com", + "name": "John+1", + "createdAt": "2014-11-30T18:48:01.123Z" + }, + { + "versionID": 1, + "comment": "added more info on doc GET and error details", + "email": "jdleesmiller+1@gmail.com", + "name": "John+1", + "createdAt": "2014-11-30T18:47:01.456Z" + } + ], + "getForVers": [ + { + "versionID": 2, + "srcs": [ + { + "content": "content\n", + "path": "main.tex" + }, + { + "content": "This text is from another file.", + "path": "test.tex" + } + ], + "atts": [ + { + "url": "http://127.0.0.1:3865/withDeletedNestedFiles/testproj/overleaf-white-410.png", + "path": "overleaf-white-410.png" + } + ] + }, + { + "versionID": 1, + "srcs": [ + { + "content": "content\n", + "path": "main.tex" + }, + { + "content": "This text is from another file.", + "path": "test.tex" + }, + { + "content": "nest1", + "path": "nest1/nest1.tex" + }, + { + "content": "nest2", + "path": "nest1/nest2/nest2.tex" + } + ], + "atts": [ + { + "url": "http://127.0.0.1:3865/base/testproj/overleaf-white-410.png", + "path": "overleaf-white-410.png" + } + ] + } + ], + "push": "success", + "postback": { + "type": "success", + "versionID": 2 + } + } +] \ No newline at end of file diff --git a/services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/canPullDeletedNestedFiles/withDeletedNestedFiles/testproj/main.tex b/services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/canPullDeletedNestedFiles/withDeletedNestedFiles/testproj/main.tex new file mode 100644 index 0000000000..d95f3ad14d --- /dev/null +++ b/services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/canPullDeletedNestedFiles/withDeletedNestedFiles/testproj/main.tex @@ -0,0 +1 @@ +content diff --git a/services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/canPullDeletedNestedFiles/withDeletedNestedFiles/testproj/overleaf-white-410.png b/services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/canPullDeletedNestedFiles/withDeletedNestedFiles/testproj/overleaf-white-410.png new file mode 100644 index 0000000000..6a23d10c15 Binary files /dev/null and b/services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/canPullDeletedNestedFiles/withDeletedNestedFiles/testproj/overleaf-white-410.png differ diff --git a/services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/canPullDeletedNestedFiles/withDeletedNestedFiles/testproj/test.tex b/services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/canPullDeletedNestedFiles/withDeletedNestedFiles/testproj/test.tex new file mode 100644 index 0000000000..046794f19a --- /dev/null +++ b/services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/canPullDeletedNestedFiles/withDeletedNestedFiles/testproj/test.tex @@ -0,0 +1 @@ +This text is from another file. \ No newline at end of file