mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 08:53:43 -05:00
canPullAModifiedBinaryFile integration test.
This commit is contained in:
parent
60ca2f1788
commit
5e8e042ad2
9 changed files with 153 additions and 3 deletions
|
@ -43,6 +43,10 @@ public class WLGitBridgeIntegrationTest {
|
|||
put("base", new SnapshotAPIStateBuilder(getResourceAsStream("/canPullADeletedTexFile/base/state.json")).build());
|
||||
put("withDeletedTexFile", new SnapshotAPIStateBuilder(getResourceAsStream("/canPullADeletedTexFile/withDeletedTexFile/state.json")).build());
|
||||
}});
|
||||
put("canPullAModifiedBinaryFile", new HashMap<String, SnapshotAPIState>() {{
|
||||
put("base", new SnapshotAPIStateBuilder(getResourceAsStream("/canPullAModifiedBinaryFile/base/state.json")).build());
|
||||
put("withModifiedBinaryFile", new SnapshotAPIStateBuilder(getResourceAsStream("/canPullAModifiedBinaryFile/withModifiedBinaryFile/state.json")).build());
|
||||
}});
|
||||
put("cannotCloneAProtectedProject", new HashMap<String, SnapshotAPIState>() {{
|
||||
put("state", new SnapshotAPIStateBuilder(getResourceAsStream("/cannotCloneAProtectedProject/state/state.json")).build());
|
||||
}});
|
||||
|
@ -108,10 +112,10 @@ public class WLGitBridgeIntegrationTest {
|
|||
assertEquals(0, exitCodeBase);
|
||||
assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/canPullAModifiedTexFile/base/testproj"), testprojDir.toPath()));
|
||||
server.setState(states.get("canPullAModifiedTexFile").get("withModifiedTexFile"));
|
||||
Process gitWithDeletedTexFile = runtime.exec("git pull", null, testprojDir);
|
||||
int exitCodeWithDeletedTexFile = gitWithDeletedTexFile.waitFor();
|
||||
Process gitWithModifiedTexFile = runtime.exec("git pull", null, testprojDir);
|
||||
int exitCodeWithModifiedTexFile = gitWithModifiedTexFile.waitFor();
|
||||
wlgb.stop();
|
||||
assertEquals(0, exitCodeWithDeletedTexFile);
|
||||
assertEquals(0, exitCodeWithModifiedTexFile);
|
||||
assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/canPullAModifiedTexFile/withModifiedTexFile/testproj"), testprojDir.toPath()));
|
||||
}
|
||||
|
||||
|
@ -138,6 +142,29 @@ public class WLGitBridgeIntegrationTest {
|
|||
assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/canPullADeletedTexFile/withDeletedTexFile/testproj"), testprojDir.toPath()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canPullAModifiedBinaryFile() throws IOException, GitAPIException, InterruptedException {
|
||||
MockSnapshotServer server = new MockSnapshotServer(3862, getResource("/canPullAModifiedBinaryFile").toFile());
|
||||
server.start();
|
||||
server.setState(states.get("canPullAModifiedBinaryFile").get("base"));
|
||||
GitBridgeApp wlgb = new GitBridgeApp(new String[] {
|
||||
makeConfigFile(33862, 3862)
|
||||
});
|
||||
wlgb.run();
|
||||
File dir = folder.newFolder();
|
||||
Process gitBase = runtime.exec("git clone http://127.0.0.1:33862/testproj.git", null, dir);
|
||||
int exitCodeBase = gitBase.waitFor();
|
||||
File testprojDir = new File(dir, "testproj");
|
||||
assertEquals(0, exitCodeBase);
|
||||
assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/canPullAModifiedBinaryFile/base/testproj"), testprojDir.toPath()));
|
||||
server.setState(states.get("canPullAModifiedBinaryFile").get("withModifiedBinaryFile"));
|
||||
Process gitWithModifiedBinaryFile = runtime.exec("git pull", null, testprojDir);
|
||||
int exitCodeWithModifiedBinaryFile = gitWithModifiedBinaryFile.waitFor();
|
||||
wlgb.stop();
|
||||
assertEquals(0, exitCodeWithModifiedBinaryFile);
|
||||
assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/canPullAModifiedBinaryFile/withModifiedBinaryFile/testproj"), testprojDir.toPath()));
|
||||
}
|
||||
|
||||
|
||||
private static final String EXPECTED_OUT_PROTECTED =
|
||||
"Cloning into 'protected'...\n" +
|
||||
|
|
|
@ -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:3862/base/testproj/overleaf-white-410.png",
|
||||
"path": "overleaf-white-410.png"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"push": "success",
|
||||
"postback": {
|
||||
"type": "success",
|
||||
"versionID": 2
|
||||
}
|
||||
}
|
||||
]
|
|
@ -0,0 +1 @@
|
|||
content
|
Binary file not shown.
After Width: | Height: | Size: 8.6 KiB |
|
@ -0,0 +1 @@
|
|||
This text is from another file.
|
|
@ -0,0 +1,72 @@
|
|||
[
|
||||
{
|
||||
"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 changed 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\nadded more stuff\n",
|
||||
"path": "main.tex"
|
||||
},
|
||||
{
|
||||
"content": "This text is from another file.",
|
||||
"path": "test.tex"
|
||||
}
|
||||
],
|
||||
"atts": [
|
||||
{
|
||||
"url": "http://127.0.0.1:3862/withModifiedBinaryFile/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"
|
||||
}
|
||||
],
|
||||
"atts": [
|
||||
{
|
||||
"url": "http://127.0.0.1:3862/base/testproj/overleaf-white-410.png",
|
||||
"path": "overleaf-white-410.png"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"push": "success",
|
||||
"postback": {
|
||||
"type": "success",
|
||||
"versionID": 2
|
||||
}
|
||||
}
|
||||
]
|
|
@ -0,0 +1,2 @@
|
|||
content
|
||||
added more stuff
|
Binary file not shown.
After Width: | Height: | Size: 3.5 KiB |
|
@ -0,0 +1 @@
|
|||
This text is from another file.
|
Loading…
Reference in a new issue