Преглед изворни кода

Added integration test for pulling a modified tex file.

Winston Li пре 11 година
родитељ
комит
a276b7c806
10 измењених фајлова са 171 додато и 0 уклоњено
  1. 24 0
      services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest.java
  2. BIN
      services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/canCloneMultipleRepositories/state/testproj2/editor-versions-a7e4de19d015c3e7477e3f7eaa6c418e.png
  3. 46 0
      services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/canPullAModifiedTexFile/base/state.json
  4. 1 0
      services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/canPullAModifiedTexFile/base/testproj/foo/bar/test.tex
  5. 1 0
      services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/canPullAModifiedTexFile/base/testproj/main.tex
  6. 12 0
      services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/canPullAModifiedTexFile/base/testproj/overleaf-white-410.png
  7. 72 0
      services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/canPullAModifiedTexFile/withModifiedTexFile/state.json
  8. 1 0
      services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/canPullAModifiedTexFile/withModifiedTexFile/testproj/foo/bar/test.tex
  9. 2 0
      services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/canPullAModifiedTexFile/withModifiedTexFile/testproj/main.tex
  10. 12 0
      services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/canPullAModifiedTexFile/withModifiedTexFile/testproj/overleaf-white-410.png

+ 24 - 0
services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest.java

@@ -32,6 +32,10 @@ public class WLGitBridgeIntegrationTest {
                 put("canCloneMultipleRepositories", new HashMap<String, SnapshotAPIState>() {{
                     put("state", new SnapshotAPIStateBuilder(getResourceAsStream("/canCloneMultipleRepositories/state/state.json")).build());
                 }});
+                put("canPullAModifiedTexFile", new HashMap<String, SnapshotAPIState>() {{
+                    put("base", new SnapshotAPIStateBuilder(getResourceAsStream("/canPullAModifiedTexFile/base/state.json")).build());
+                    put("withModifiedTexFile", new SnapshotAPIStateBuilder(getResourceAsStream("/canPullAModifiedTexFile/withModifiedTexFile/state.json")).build());
+                }});
             }};
 
     @Rule
@@ -84,6 +88,26 @@ public class WLGitBridgeIntegrationTest {
         assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/canCloneMultipleRepositories/state/testproj2"), testproj2.toPath()));
     }
 
+    @Test
+    public void canPullAModifiedTexFile() throws IOException, GitAPIException {
+        MockSnapshotServer server = new MockSnapshotServer(3859, getResource("/canPullAModifiedTexFile").toFile());
+        server.start();
+        server.setState(states.get("canPullAModifiedTexFile").get("base"));
+        WLGitBridgeApplication wlgb = new WLGitBridgeApplication(new String[] {
+                makeConfigFile(33859, 3859)
+        });
+        wlgb.run();
+        folder.create();
+        File git = folder.newFolder();
+        Git.cloneRepository()
+                .setURI("http://127.0.0.1:33859/testproj.git")
+                .setDirectory(git)
+                .call()
+                .close();
+        wlgb.stop();
+        assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/canPullAModifiedTexFile/base/testproj"), git.toPath()));
+    }
+
     private String makeConfigFile(int port, int apiPort) throws IOException {
         File wlgb = folder.newFolder();
         File config = folder.newFile();

BIN
services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/canCloneMultipleRepositories/state/testproj2/editor-versions-a7e4de19d015c3e7477e3f7eaa6c418e.png


+ 46 - 0
services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/canPullAModifiedTexFile/base/state.json

@@ -0,0 +1,46 @@
+[
+	{
+		"project": "testproj",
+		"getDoc": {
+			"versionID": 1,
+			"createdAt": "2014-11-30T18:40:58Z",
+			"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:01Z"
+        	}
+		],
+		"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:3859/base/testproj/overleaf-white-410.png",
+	            		"path": "overleaf-white-410.png"
+	            	}
+	            ]
+	        }
+		],
+		"push": "success",
+		"postback": {
+			"type": "success",
+			"versionID": 2
+		}
+	}
+]

+ 1 - 0
services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/canPullAModifiedTexFile/base/testproj/foo/bar/test.tex

@@ -0,0 +1 @@
+This text is from another file.

+ 1 - 0
services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/canPullAModifiedTexFile/base/testproj/main.tex

@@ -0,0 +1 @@
+content

+ 12 - 0
services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/canPullAModifiedTexFile/base/testproj/overleaf-white-410.png

@@ -0,0 +1,12 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>
+<title>Error 404 </title>
+</head>
+<body>
+<h2>HTTP ERROR: 404</h2>
+<p>Problem accessing /state/testproj1/overleaf-white-410.png. Reason:
+<pre>    Not Found</pre></p>
+<hr /><i><small>Powered by Jetty://</small></i>
+</body>
+</html>

+ 72 - 0
services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/canPullAModifiedTexFile/withModifiedTexFile/state.json

@@ -0,0 +1,72 @@
+[
+	{
+		"project": "testproj",
+		"getDoc": {
+			"versionID": 2,
+			"createdAt": "2014-11-30T18:40:58Z",
+			"email": "jdleesmiller+1@gmail.com",
+			"name": "John+1"
+		},
+		"getSavedVers": [
+        	{
+        		"versionID": 2,
+        		"comment": "i added more stuff to main.tex",
+        		"email": "jdleesmiller+1@gmail.com",
+        		"name": "John+1",
+        		"createdAt": "2014-11-30T18:48:01Z"
+        	},
+        	{
+        		"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:01Z"
+        	}
+		],
+		"getForVers": [
+			{
+				"versionID": 2,
+				"srcs": [
+                    {
+                    	"content": "content\nadded more stuff\n",
+                    	"path": "main.tex"
+                    },
+                    {
+                    	"content": "This text is from another file.",
+                    	"path": "foo/bar/test.tex"
+                    }
+	            ],
+	            "atts": [
+	            	{
+	            		"url": "http://127.0.0.1:3859/withModifiedTexFile/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": "foo/bar/test.tex"
+                    }
+	            ],
+	            "atts": [
+	            	{
+	            		"url": "http://127.0.0.1:3857/base/testproj/overleaf-white-410.png",
+	            		"path": "overleaf-white-410.png"
+	            	}
+	            ]
+	        }
+		],
+		"push": "success",
+		"postback": {
+			"type": "success",
+			"versionID": 2
+		}
+	}
+]

+ 1 - 0
services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/canPullAModifiedTexFile/withModifiedTexFile/testproj/foo/bar/test.tex

@@ -0,0 +1 @@
+This text is from another file.

+ 2 - 0
services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/canPullAModifiedTexFile/withModifiedTexFile/testproj/main.tex

@@ -0,0 +1,2 @@
+content
+added more stuff

+ 12 - 0
services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/canPullAModifiedTexFile/withModifiedTexFile/testproj/overleaf-white-410.png

@@ -0,0 +1,12 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>
+<title>Error 404 </title>
+</head>
+<body>
+<h2>HTTP ERROR: 404</h2>
+<p>Problem accessing /state/testproj1/overleaf-white-410.png. Reason:
+<pre>    Not Found</pre></p>
+<hr /><i><small>Powered by Jetty://</small></i>
+</body>
+</html>