Updated old lockfile tests
authorRay Tung <raytung@users.noreply.github.com>
Tue, 3 Oct 2017 14:57:49 +0000 (01:57 +1100)
committerRay Tung <raytung@users.noreply.github.com>
Tue, 3 Oct 2017 14:57:49 +0000 (01:57 +1100)
tests/lockfile-compat.rs

index ffb3900da52be97fadd22d01cf3fe9bc9e2f3302..d9f6791687cc288c673a1c605c52c18ff42544f2 100644 (file)
@@ -8,6 +8,16 @@ use hamcrest::assert_that;
 
 #[test]
 fn oldest_lockfile_still_works() {
+    let cargo_commands = vec![
+        "build",
+        "update"
+    ];
+    for cargo_command in cargo_commands {
+        oldest_lockfile_still_works_with_command(cargo_command);
+    }
+}
+
+fn oldest_lockfile_still_works_with_command(cargo_command: &str) {
     Package::new("foo", "0.1.0").publish();
 
     let expected_lockfile =
@@ -53,24 +63,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
         "#)
         .file("src/lib.rs", "")
         .file("Cargo.lock", old_lockfile);
-    p.build();
-
-    let cargo_commands = vec![
-        "build",
-        "update"
-    ];
 
-    for cargo_command in cargo_commands {
-        assert_that(p.cargo(cargo_command),
-                    execs().with_status(0));
+    p.build();
 
-        let lock = p.read_lockfile();
-        for (l, r) in expected_lockfile.lines().zip(lock.lines()) {
-            assert!(lines_match(l, r), "Lines differ:\n{}\n\n{}", l, r);
-        }
+    assert_that(p.cargo(cargo_command),
+                execs().with_status(0));
 
-        assert_eq!(lock.lines().count(), expected_lockfile.lines().count());
+    let lock = p.read_lockfile();
+    for (l, r) in expected_lockfile.lines().zip(lock.lines()) {
+        assert!(lines_match(l, r), "Lines differ:\n{}\n\n{}", l, r);
     }
+
+    assert_eq!(lock.lines().count(), expected_lockfile.lines().count());
 }
 
 #[test]