Add test for f385cffd

This commit is contained in:
Winston Li 2015-08-04 20:32:41 +01:00
parent f2701568f6
commit 34c2d7f613
10 changed files with 154 additions and 1 deletions

View file

@ -56,8 +56,12 @@ public class WLGitBridgeIntegrationTest {
put("base", new SnapshotAPIStateBuilder(getResourceAsStream("/canPullADeletedBinaryFile/base/state.json")).build());
put("withDeletedBinaryFile", new SnapshotAPIStateBuilder(getResourceAsStream("/canPullADeletedBinaryFile/withDeletedBinaryFile/state.json")).build());
}});
put("canPullADuplicateBinaryFile", new HashMap<String, SnapshotAPIState>() {{
put("base", new SnapshotAPIStateBuilder(getResourceAsStream("/canPullADuplicateBinaryFile/base/state.json")).build());
put("withDuplicateBinaryFile", new SnapshotAPIStateBuilder(getResourceAsStream("/canPullADuplicateBinaryFile/withDuplicateBinaryFile/state.json")).build());
}});
put("canPullAModifiedNestedFile", new HashMap<String, SnapshotAPIState>() {{
put("base", new SnapshotAPIStateBuilder(getResourceAsStream("/canPullADeletedBinaryFile/base/state.json")).build());
put("base", new SnapshotAPIStateBuilder(getResourceAsStream("/canPullAModifiedNestedFile/base/state.json")).build());
put("withModifiedNestedFile", new SnapshotAPIStateBuilder(getResourceAsStream("/canPullAModifiedNestedFile/withModifiedNestedFile/state.json")).build());
}});
put("canPullDeletedNestedFiles", new HashMap<String, SnapshotAPIState>() {{
@ -246,6 +250,29 @@ public class WLGitBridgeIntegrationTest {
assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/canPullADeletedBinaryFile/withDeletedBinaryFile/testproj"), testprojDir.toPath()));
}
@Test
public void canPullADuplicateBinaryFile() throws IOException, GitAPIException, InterruptedException {
MockSnapshotServer server = new MockSnapshotServer(4001, getResource("/canPullADuplicateBinaryFile").toFile());
server.start();
server.setState(states.get("canPullADuplicateBinaryFile").get("base"));
GitBridgeApp wlgb = new GitBridgeApp(new String[] {
makeConfigFile(44001, 4001)
});
wlgb.run();
File dir = folder.newFolder();
Process gitBase = runtime.exec("git clone http://127.0.0.1:44001/testproj.git", null, dir);
int exitCodeBase = gitBase.waitFor();
File testprojDir = new File(dir, "testproj");
assertEquals(0, exitCodeBase);
assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/canPullADuplicateBinaryFile/base/testproj"), testprojDir.toPath()));
server.setState(states.get("canPullADuplicateBinaryFile").get("withDuplicateBinaryFile"));
Process gitWithDeletedBinaryFile = runtime.exec("git pull", null, testprojDir);
int exitCodeWithDeletedBinaryFile = gitWithDeletedBinaryFile.waitFor();
wlgb.stop();
assertEquals(0, exitCodeWithDeletedBinaryFile);
assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/canPullADuplicateBinaryFile/withDuplicateBinaryFile/testproj"), testprojDir.toPath()));
}
@Test
public void canPullAModifiedNestedFile() throws IOException, GitAPIException, InterruptedException {
MockSnapshotServer server = new MockSnapshotServer(3864, getResource("/canPullAModifiedNestedFile").toFile());

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:4001/base/testproj/overleaf-white-410.png",
"path": "overleaf-white-410.png"
}
]
}
],
"push": "success",
"postback": {
"type": "success",
"versionID": 2
}
}
]

View file

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