mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-31 21:01:33 +02:00
pushFailsOnFirstStageOutOfDate integration test.
This commit is contained in:
@@ -65,6 +65,9 @@ public class WLGitBridgeIntegrationTest {
|
||||
put("canPushFilesSuccessfully", new HashMap<String, SnapshotAPIState>() {{
|
||||
put("state", new SnapshotAPIStateBuilder(getResourceAsStream("/canPushFilesSuccessfully/state/state.json")).build());
|
||||
}});
|
||||
put("pushFailsOnFirstStageOutOfDate", new HashMap<String, SnapshotAPIState>() {{
|
||||
put("state", new SnapshotAPIStateBuilder(getResourceAsStream("/pushFailsOnFirstStageOutOfDate/state/state.json")).build());
|
||||
}});
|
||||
}};
|
||||
|
||||
@Rule
|
||||
@@ -295,6 +298,42 @@ public class WLGitBridgeIntegrationTest {
|
||||
assertEquals(0, pushExitCode);
|
||||
}
|
||||
|
||||
|
||||
private static final String EXPECTED_OUT_PUSH_FAIL_FIRST_STAGE =
|
||||
"To http://127.0.0.1:33867/testproj.git\n" +
|
||||
" ! [rejected] master -> master (non-fast-forward)\n" +
|
||||
"error: failed to push some refs to 'http://127.0.0.1:33867/testproj.git'\n" +
|
||||
"hint: Updates were rejected because the tip of your current branch is behind\n" +
|
||||
"hint: its remote counterpart. Integrate the remote changes (e.g.\n" +
|
||||
"hint: 'git pull ...') before pushing again.\n" +
|
||||
"hint: See the 'Note about fast-forwards' in 'git push --help' for details.\n";
|
||||
|
||||
@Test
|
||||
public void pushFailsOnFirstStageOutOfDate() throws IOException, GitAPIException, InterruptedException {
|
||||
MockSnapshotServer server = new MockSnapshotServer(3867, getResource("/pushFailsOnFirstStageOutOfDate").toFile());
|
||||
server.start();
|
||||
server.setState(states.get("pushFailsOnFirstStageOutOfDate").get("state"));
|
||||
GitBridgeApp wlgb = new GitBridgeApp(new String[] {
|
||||
makeConfigFile(33867, 3867)
|
||||
});
|
||||
wlgb.run();
|
||||
File dir = folder.newFolder();
|
||||
Process git = runtime.exec("git clone http://127.0.0.1:33867/testproj.git", null, dir);
|
||||
int exitCode = git.waitFor();
|
||||
File testprojDir = new File(dir, "testproj");
|
||||
assertEquals(0, exitCode);
|
||||
assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/pushFailsOnFirstStageOutOfDate/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);
|
||||
assertEquals(EXPECTED_OUT_PUSH_FAIL_FIRST_STAGE, Util.fromStream(gitPush.getErrorStream(), 2));
|
||||
}
|
||||
|
||||
private String makeConfigFile(int port, int apiPort) throws IOException {
|
||||
File wlgb = folder.newFolder();
|
||||
File config = folder.newFile();
|
||||
|
||||
Reference in New Issue
Block a user