mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Add test for reset before pull
This commit is contained in:
parent
d07ecd2a1b
commit
935770e2ab
7 changed files with 123 additions and 0 deletions
|
@ -147,6 +147,10 @@ public class WLGitBridgeIntegrationTest {
|
||||||
put("cannotCloneAHasDotGitProject", new HashMap<String, SnapshotAPIState>() {{
|
put("cannotCloneAHasDotGitProject", new HashMap<String, SnapshotAPIState>() {{
|
||||||
put("state", new SnapshotAPIStateBuilder(getResourceAsStream("/cannotCloneAHasDotGitProject/state/state.json")).build());
|
put("state", new SnapshotAPIStateBuilder(getResourceAsStream("/cannotCloneAHasDotGitProject/state/state.json")).build());
|
||||||
}});
|
}});
|
||||||
|
put("canPullIgnoredForceAddedFile", new HashMap<String, SnapshotAPIState>() {{
|
||||||
|
put("base", new SnapshotAPIStateBuilder(getResourceAsStream("/canPullIgnoredForceAddedFile/base/state.json")).build());
|
||||||
|
put("withUpdatedMainFile", new SnapshotAPIStateBuilder(getResourceAsStream("/canPullIgnoredForceAddedFile/withUpdatedMainFile/state.json")).build());
|
||||||
|
}});
|
||||||
}};
|
}};
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
|
@ -995,6 +999,34 @@ public class WLGitBridgeIntegrationTest {
|
||||||
assertTrue(responseString.contains("Git LFS is not supported on Overleaf"));
|
assertTrue(responseString.contains("Git LFS is not supported on Overleaf"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void canPullIgnoredForceAddedFile() throws IOException, InterruptedException {
|
||||||
|
int gitBridgePort = 33891;
|
||||||
|
int mockServerPort = 3891;
|
||||||
|
server = new MockSnapshotServer(mockServerPort, getResource("/canPullIgnoredForceAddedFile").toFile());
|
||||||
|
server.start();
|
||||||
|
server.setState(states.get("canPullIgnoredForceAddedFile").get("base"));
|
||||||
|
wlgb = new GitBridgeApp(new String[] {
|
||||||
|
makeConfigFile(gitBridgePort, mockServerPort)
|
||||||
|
});
|
||||||
|
wlgb.run();
|
||||||
|
File testProjDir = gitClone("testproj", gitBridgePort, dir);
|
||||||
|
File one = new File(testProjDir, "sub/one.txt");
|
||||||
|
one.createNewFile();
|
||||||
|
FileWriter fw = new FileWriter(one.getPath());
|
||||||
|
fw.write("1");
|
||||||
|
fw.close();
|
||||||
|
assertEquals(0, runtime.exec(
|
||||||
|
"git add -A -f", null, testProjDir
|
||||||
|
).waitFor());
|
||||||
|
gitCommit(testProjDir, "push");
|
||||||
|
gitPush(testProjDir);
|
||||||
|
server.setState(states.get("canPullIgnoredForceAddedFile").get("withUpdatedMainFile"));
|
||||||
|
gitPull(testProjDir);
|
||||||
|
File f = new File(testProjDir.getPath() + "/sub/one.txt");
|
||||||
|
assertTrue(f.exists());
|
||||||
|
}
|
||||||
|
|
||||||
private String makeConfigFile(
|
private String makeConfigFile(
|
||||||
int port,
|
int port,
|
||||||
int apiPort
|
int apiPort
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"project": "testproj",
|
||||||
|
"getDoc": {
|
||||||
|
"versionID": 1,
|
||||||
|
"createdAt": "2014-11-30T18:40:58.123Z",
|
||||||
|
"email": "jdleesmiller+1@gmail.com",
|
||||||
|
"name": "John+1"
|
||||||
|
},
|
||||||
|
"getSavedVers": [
|
||||||
|
{
|
||||||
|
"versionID": 1,
|
||||||
|
"comment": "init",
|
||||||
|
"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": "*.txt",
|
||||||
|
"path": "sub/.gitignore"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"atts": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"push": "success",
|
||||||
|
"postback": {
|
||||||
|
"type": "success",
|
||||||
|
"versionID": 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
|
@ -0,0 +1 @@
|
||||||
|
content
|
|
@ -0,0 +1 @@
|
||||||
|
*.txt
|
|
@ -0,0 +1,45 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"project": "testproj",
|
||||||
|
"getDoc": {
|
||||||
|
"versionID": 5,
|
||||||
|
"createdAt": "2014-11-30T18:40:58.123Z",
|
||||||
|
"email": "jdleesmiller+1@gmail.com",
|
||||||
|
"name": "John+1"
|
||||||
|
},
|
||||||
|
"getSavedVers": [
|
||||||
|
{
|
||||||
|
"versionID": 5,
|
||||||
|
"comment": "init",
|
||||||
|
"email": "jdleesmiller+1@gmail.com",
|
||||||
|
"name": "John+1",
|
||||||
|
"createdAt": "2014-11-30T18:47:01.456Z"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"getForVers": [
|
||||||
|
{
|
||||||
|
"versionID": 5,
|
||||||
|
"srcs": [
|
||||||
|
{
|
||||||
|
"content": "content\nupdated\n",
|
||||||
|
"path": "main.tex"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"content": "*.txt",
|
||||||
|
"path": "sub/.gitignore"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"content": "1",
|
||||||
|
"path": "sub/one.txt"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"atts": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"push": "success",
|
||||||
|
"postback": {
|
||||||
|
"type": "success",
|
||||||
|
"versionID": 5
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
|
@ -0,0 +1,2 @@
|
||||||
|
content
|
||||||
|
updated
|
|
@ -0,0 +1 @@
|
||||||
|
*.txt
|
Loading…
Reference in a new issue