mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-14 18:04:16 +00:00
pushFailsOnUnexpectedError integration test.
This commit is contained in:
parent
a0eb4b0946
commit
d697f75c77
6 changed files with 89 additions and 1 deletions
|
@ -18,7 +18,7 @@ public class SnapshotPostExceptionBuilder {
|
|||
} else if (errorCode.equals(CODE_ERROR_INVALID_FILES)) {
|
||||
return new InvalidFilesException(json);
|
||||
} else if (errorCode.equals(CODE_ERROR_INVALID_PROJECT)) {
|
||||
return new uk.ac.ic.wlgitbridge.snapshot.getdoc.exception.InvalidProjectException(json);
|
||||
return new InvalidProjectException(json);
|
||||
} else if (errorCode.equals(CODE_ERROR_UNKNOWN)) {
|
||||
return new UnexpectedErrorException(json);
|
||||
} else {
|
||||
|
|
|
@ -79,6 +79,9 @@ public class WLGitBridgeIntegrationTest {
|
|||
put("pushFailsOnInvalidProject", new HashMap<String, SnapshotAPIState>() {{
|
||||
put("state", new SnapshotAPIStateBuilder(getResourceAsStream("/pushFailsOnInvalidProject/state/state.json")).build());
|
||||
}});
|
||||
put("pushFailsOnUnexpectedError", new HashMap<String, SnapshotAPIState>() {{
|
||||
put("state", new SnapshotAPIStateBuilder(getResourceAsStream("/pushFailsOnUnexpectedError/state/state.json")).build());
|
||||
}});
|
||||
}};
|
||||
|
||||
@Rule
|
||||
|
@ -456,6 +459,44 @@ public class WLGitBridgeIntegrationTest {
|
|||
assertEquals(EXPECTED_OUT_PUSH_INVALID_PROJECT, actual);
|
||||
}
|
||||
|
||||
|
||||
private static final List<String> EXPECTED_OUT_PUSH_UNEXPECTED_ERROR =
|
||||
Arrays.asList(
|
||||
"remote: error: Overleaf error",
|
||||
"remote: hint: There was an internal error with the Overleaf server.",
|
||||
"remote: hint: Please contact Overleaf.",
|
||||
"To http://127.0.0.1:33871/testproj.git",
|
||||
"! [remote rejected] master -> master (Overleaf error)",
|
||||
"error: failed to push some refs to 'http://127.0.0.1:33871/testproj.git'"
|
||||
);
|
||||
|
||||
/* this one prints a stack trace */
|
||||
@Test
|
||||
public void pushFailsOnUnexpectedError() throws IOException, GitAPIException, InterruptedException {
|
||||
MockSnapshotServer server = new MockSnapshotServer(3871, getResource("/pushFailsOnUnexpectedError").toFile());
|
||||
server.start();
|
||||
server.setState(states.get("pushFailsOnUnexpectedError").get("state"));
|
||||
GitBridgeApp wlgb = new GitBridgeApp(new String[] {
|
||||
makeConfigFile(33871, 3871)
|
||||
});
|
||||
wlgb.run();
|
||||
File dir = folder.newFolder();
|
||||
Process git = runtime.exec("git clone http://127.0.0.1:33871/testproj.git", null, dir);
|
||||
int exitCode = git.waitFor();
|
||||
File testprojDir = new File(dir, "testproj");
|
||||
assertEquals(0, exitCode);
|
||||
assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/pushFailsOnUnexpectedError/state/testproj"), testprojDir.toPath()));
|
||||
runtime.exec("touch push.tex", null, testprojDir).waitFor();
|
||||
runtime.exec("git add -A", null, testprojDir).waitFor();
|
||||
runtime.exec("git commit -m \"push\"", null, testprojDir).waitFor();
|
||||
Process gitPush = runtime.exec("git push", null, testprojDir);
|
||||
int pushExitCode = gitPush.waitFor();
|
||||
wlgb.stop();
|
||||
assertEquals(1, pushExitCode);
|
||||
List<String> actual = Util.linesFromStream(gitPush.getErrorStream(), 2, "[K");
|
||||
assertEquals(EXPECTED_OUT_PUSH_UNEXPECTED_ERROR, actual);
|
||||
}
|
||||
|
||||
private String makeConfigFile(int port, int apiPort) throws IOException {
|
||||
File wlgb = folder.newFolder();
|
||||
File config = folder.newFile();
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
[
|
||||
{
|
||||
"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.333Z"
|
||||
}
|
||||
],
|
||||
"getForVers": [
|
||||
{
|
||||
"versionID": 1,
|
||||
"srcs": [
|
||||
{
|
||||
"content": "content\n",
|
||||
"path": "main.tex"
|
||||
},
|
||||
{
|
||||
"content": "This text is from another file.",
|
||||
"path": "foo/bar/test.tex"
|
||||
}
|
||||
],
|
||||
"atts": [
|
||||
{
|
||||
"url": "http://127.0.0.1:3871/state/testproj/min_mean_wait_evm_7_eps_150dpi.png",
|
||||
"path": "min_mean_wait_evm_7_eps_150dpi.png"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"push": "success",
|
||||
"postback": {
|
||||
"type": "error"
|
||||
}
|
||||
}
|
||||
]
|
|
@ -0,0 +1 @@
|
|||
This text is from another file.
|
|
@ -0,0 +1 @@
|
|||
content
|
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
Loading…
Add table
Reference in a new issue