pushFailsOnSecondStageOutOfDate integration test.

This commit is contained in:
Winston Li 2015-03-10 00:19:12 +00:00
parent d1156cb812
commit 7e803bb950
5 changed files with 87 additions and 4 deletions

View file

@ -68,6 +68,9 @@ public class WLGitBridgeIntegrationTest {
put("pushFailsOnFirstStageOutOfDate", new HashMap<String, SnapshotAPIState>() {{
put("state", new SnapshotAPIStateBuilder(getResourceAsStream("/pushFailsOnFirstStageOutOfDate/state/state.json")).build());
}});
put("pushFailsOnSecondStageOutOfDate", new HashMap<String, SnapshotAPIState>() {{
put("state", new SnapshotAPIStateBuilder(getResourceAsStream("/pushFailsOnSecondStageOutOfDate/state/state.json")).build());
}});
}};
@Rule
@ -299,7 +302,7 @@ public class WLGitBridgeIntegrationTest {
}
private static final String EXPECTED_OUT_PUSH_FAIL_FIRST_STAGE =
private static final String EXPECTED_OUT_PUSH_OUT_OF_DATE_FIRST =
"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" +
@ -327,10 +330,43 @@ public class WLGitBridgeIntegrationTest {
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();
gitPush.waitFor();
wlgb.stop();
assertEquals(EXPECTED_OUT_PUSH_FAIL_FIRST_STAGE, Util.fromStream(gitPush.getErrorStream(), 2));
assertEquals(EXPECTED_OUT_PUSH_OUT_OF_DATE_FIRST, Util.fromStream(gitPush.getErrorStream(), 2));
}
private static final String EXPECTED_OUT_PUSH_OUT_OF_DATE_SECOND =
"To http://127.0.0.1:33868/testproj.git\n" +
" ! [rejected] master -> master (non-fast-forward)\n" +
"error: failed to push some refs to 'http://127.0.0.1:33868/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 pushFailsOnSecondStageOutOfDate() throws IOException, GitAPIException, InterruptedException {
MockSnapshotServer server = new MockSnapshotServer(3868, getResource("/pushFailsOnSecondStageOutOfDate").toFile());
server.start();
server.setState(states.get("pushFailsOnSecondStageOutOfDate").get("state"));
GitBridgeApp wlgb = new GitBridgeApp(new String[] {
makeConfigFile(33868, 3868)
});
wlgb.run();
File dir = folder.newFolder();
Process git = runtime.exec("git clone http://127.0.0.1:33868/testproj.git", null, dir);
int exitCode = git.waitFor();
File testprojDir = new File(dir, "testproj");
assertEquals(0, exitCode);
assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/pushFailsOnSecondStageOutOfDate/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);
gitPush.waitFor();
wlgb.stop();
assertEquals(EXPECTED_OUT_PUSH_OUT_OF_DATE_SECOND, Util.fromStream(gitPush.getErrorStream(), 2));
}
private String makeConfigFile(int port, int apiPort) throws IOException {

View file

@ -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:3868/state/testproj/min_mean_wait_evm_7_eps_150dpi.png",
"path": "min_mean_wait_evm_7_eps_150dpi.png"
}
]
}
],
"push": "outOfDate",
"postback": {
"type": "outOfDate"
}
}
]