canPullADeletedBinaryFile integration test.

This commit is contained in:
Winston Li 2015-03-09 23:08:53 +00:00
parent 5e8e042ad2
commit f0f5333161
8 changed files with 145 additions and 0 deletions

View file

@ -47,6 +47,10 @@ public class WLGitBridgeIntegrationTest {
put("base", new SnapshotAPIStateBuilder(getResourceAsStream("/canPullAModifiedBinaryFile/base/state.json")).build()); put("base", new SnapshotAPIStateBuilder(getResourceAsStream("/canPullAModifiedBinaryFile/base/state.json")).build());
put("withModifiedBinaryFile", new SnapshotAPIStateBuilder(getResourceAsStream("/canPullAModifiedBinaryFile/withModifiedBinaryFile/state.json")).build()); put("withModifiedBinaryFile", new SnapshotAPIStateBuilder(getResourceAsStream("/canPullAModifiedBinaryFile/withModifiedBinaryFile/state.json")).build());
}}); }});
put("canPullADeletedBinaryFile", new HashMap<String, SnapshotAPIState>() {{
put("base", new SnapshotAPIStateBuilder(getResourceAsStream("/canPullADeletedBinaryFile/base/state.json")).build());
put("withDeletedBinaryFile", new SnapshotAPIStateBuilder(getResourceAsStream("/canPullADeletedBinaryFile/withDeletedBinaryFile/state.json")).build());
}});
put("cannotCloneAProtectedProject", new HashMap<String, SnapshotAPIState>() {{ put("cannotCloneAProtectedProject", new HashMap<String, SnapshotAPIState>() {{
put("state", new SnapshotAPIStateBuilder(getResourceAsStream("/cannotCloneAProtectedProject/state/state.json")).build()); put("state", new SnapshotAPIStateBuilder(getResourceAsStream("/cannotCloneAProtectedProject/state/state.json")).build());
}}); }});
@ -165,6 +169,29 @@ public class WLGitBridgeIntegrationTest {
assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/canPullAModifiedBinaryFile/withModifiedBinaryFile/testproj"), testprojDir.toPath())); assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/canPullAModifiedBinaryFile/withModifiedBinaryFile/testproj"), testprojDir.toPath()));
} }
@Test
public void canPullADeletedBinaryFile() throws IOException, GitAPIException, InterruptedException {
MockSnapshotServer server = new MockSnapshotServer(3863, getResource("/canPullADeletedBinaryFile").toFile());
server.start();
server.setState(states.get("canPullADeletedBinaryFile").get("base"));
GitBridgeApp wlgb = new GitBridgeApp(new String[] {
makeConfigFile(33863, 3863)
});
wlgb.run();
File dir = folder.newFolder();
Process gitBase = runtime.exec("git clone http://127.0.0.1:33863/testproj.git", null, dir);
int exitCodeBase = gitBase.waitFor();
File testprojDir = new File(dir, "testproj");
assertEquals(0, exitCodeBase);
assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/canPullADeletedBinaryFile/base/testproj"), testprojDir.toPath()));
server.setState(states.get("canPullADeletedBinaryFile").get("withDeletedBinaryFile"));
Process gitWithModifiedBinaryFile = runtime.exec("git pull", null, testprojDir);
int exitCodeWithModifiedBinaryFile = gitWithModifiedBinaryFile.waitFor();
wlgb.stop();
assertEquals(0, exitCodeWithModifiedBinaryFile);
assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/canPullADeletedBinaryFile/withDeletedBinaryFile/testproj"), testprojDir.toPath()));
}
private static final String EXPECTED_OUT_PROTECTED = private static final String EXPECTED_OUT_PROTECTED =
"Cloning into 'protected'...\n" + "Cloning into 'protected'...\n" +

View file

@ -0,0 +1,46 @@
[
{
"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"
}
],
"atts": [
{
"url": "http://127.0.0.1:3863/base/testproj/overleaf-white-410.png",
"path": "overleaf-white-410.png"
}
]
}
],
"push": "success",
"postback": {
"type": "success",
"versionID": 2
}
}
]

View file

@ -0,0 +1,68 @@
[
{
"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 the image",
"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": [
]
},
{
"versionID": 1,
"srcs": [
{
"content": "content\n",
"path": "main.tex"
},
{
"content": "This text is from another file.",
"path": "test.tex"
}
],
"atts": [
{
"url": "http://127.0.0.1:3863/base/testproj/overleaf-white-410.png",
"path": "overleaf-white-410.png"
}
]
}
],
"push": "success",
"postback": {
"type": "success",
"versionID": 2
}
}
]