فهرست منبع

Add a test for when migrated-from project is not present

Shane Kilkelly 7 سال پیش
والد
کامیت
c553094a60

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

@@ -120,6 +120,9 @@ public class WLGitBridgeIntegrationTest {
         put("canMigrateRepository", new HashMap<String, SnapshotAPIState>() {{
             put("state", new SnapshotAPIStateBuilder(getResourceAsStream("/canMigrateRepository/state/state.json")).build());
         }});
+        put("skipMigrationWhenMigratedFromMissing", new HashMap<String, SnapshotAPIState>() {{
+            put("state", new SnapshotAPIStateBuilder(getResourceAsStream("/skipMigrationWhenMigratedFromMissing/state/state.json")).build());
+        }});
     }};
 
     @Rule
@@ -805,9 +808,28 @@ public class WLGitBridgeIntegrationTest {
         File testprojDir2 = gitClone("testproj2", gitBridgePort, dir);
         wlgb.stop();
 
+        // Second project content is equal to content of the first
         assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/canMigrateRepository/state/testproj"), testprojDir2.toPath()));
     }
 
+    @Test
+    public void skipMigrationWhenMigratedFromMissing() throws IOException, GitAPIException, InterruptedException {
+        int gitBridgePort = 33882;
+        int mockServerPort = 3882;
+        MockSnapshotServer server = new MockSnapshotServer(mockServerPort, getResource("/skipMigrationWhenMigratedFromMissing").toFile());
+        server.start();
+        server.setState(states.get("skipMigrationWhenMigratedFromMissing").get("state"));
+        GitBridgeApp wlgb = new GitBridgeApp(new String[] {
+                makeConfigFile(gitBridgePort, mockServerPort)
+        });
+        wlgb.run();
+        // don't clone the source project first
+        File testprojDir2 = gitClone("testproj2", gitBridgePort, dir);
+        wlgb.stop();
+
+        assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/skipMigrationWhenMigratedFromMissing/state/testproj2"), testprojDir2.toPath()));
+    }
+
     private String makeConfigFile(
             int port,
             int apiPort

+ 39 - 0
services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/skipMigrationWhenMigratedFromMissing/state/state.json

@@ -0,0 +1,39 @@
+[
+  {
+    "project": "testproj2",
+    "getDoc": {
+      "versionID": 1,
+      "createdAt": "2014-11-30T18:40:58.123Z",
+      "email": "jdleesmiller+1@gmail.com",
+      "name": "John+1",
+      "migratedFromId": "testprojthatdoesnotexist"
+    },
+    "getSavedVers": [],
+    "getForVers": [
+      {
+        "versionID": 1,
+        "srcs": [
+          {
+            "content": "two\n",
+            "path": "main.tex"
+          },
+          {
+            "content": "This text is from another file.",
+            "path": "foo/bar/test.tex"
+          }
+        ],
+        "atts": [
+          {
+            "url": "http://127.0.0.1:3857/state/testproj/min_mean_wait_evm_7_eps_150dpi.png",
+            "path": "min_mean_wait_evm_7_eps_150dpi.png"
+          }
+        ]
+      }
+    ],
+    "push": "success",
+    "postback": {
+      "type": "success",
+      "versionID": 2
+    }
+  }
+]

+ 1 - 0
services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/skipMigrationWhenMigratedFromMissing/state/testproj2/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/skipMigrationWhenMigratedFromMissing/state/testproj2/main.tex

@@ -0,0 +1 @@
+two

BIN
services/git-bridge/src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest/skipMigrationWhenMigratedFromMissing/state/testproj2/min_mean_wait_evm_7_eps_150dpi.png