History

the first successful test (#450)

Sebastian Thiel committed 4 years ago

Commit e4edc181 parent 9f9b6102 files · +16 −7Browse files

Unified · Split

2 files
  1. git-repository/src/remote/connection/fetch/update_refs/tests.rs +14 −6
  2. git-repository/tests/fixtures/make_fetch_repos.sh +2 −1
git-repository/src/remote/connection/fetch/update_refs/tests.rs+14−6
@@ -21,32 +21,40 @@ mod update { · 20 unmodified lines
2121 use git_ref::TargetRef;
2222
2323 #[test]
24− #[ignore]
2524 fn various_valid_updates() {
2625 let repo = repo("two-origins");
2726 // TODO: test reflog message (various cases if it's new)
28− for (spec, expected_mode, detail) in [
27+ for (spec, expected_mode, has_edit_index, detail) in [
2928 (
3029 "refs/heads/main:refs/remotes/origin/main",
3130 fetch::refs::update::Mode::NoChangeNeeded,
31+ true,
3232 "these refs are en-par since the initial clone",
3333 ),
3434 (
3535 "refs/heads/main",
3636 fetch::refs::update::Mode::NoChangeNeeded,
37+ false,
3738 "without local destination ref there is nothing to do for us, ever (except for FETCH_HEADs) later",
3839 ),
3940 (
4041 "refs/heads/main:refs/remotes/origin/new-main",
4142 fetch::refs::update::Mode::New,
43+ true,
4244 "the destination branch doesn't exist and needs to be created",
4345 ),
4446 (
45− "+refs/heads/main:refs/heads/g",
47+ "+refs/heads/main:refs/remotes/origin/g",
4648 fetch::refs::update::Mode::Forced,
49+ true,
4750 "a forced non-fastforward (main goes backwards)",
4851 ),
49− // ("refs/heads/g:refs/heads/main", fetch::refs::update::Mode::FastForward, "a fast-forward only fast-forward situation, all good"),
52+ // (
53+ // "refs/remotes/origin/g:refs/heads/not-currently-checked-out",
54+ // fetch::refs::update::Mode::FastForward,
55+ // true,
56+ // "a fast-forward only fast-forward situation, all good",
57+ // ),
5058 ] {
5159 let (mapping, specs) = mapping_from_spec(spec, &repo);
5260 let out = fetch::refs::update(&repo, &mapping, &specs, fetch::DryRun::Yes).unwrap();
@@ -55,12 +63,12 @@ mod update { · 2 unmodified lines
5563 out.updates,
5664 vec![fetch::refs::Update {
5765 mode: expected_mode,
58− edit_index: Some(0),
66+ edit_index: has_edit_index.then(|| 0),
5967 spec_index: 0
6068 }],
6169 "{spec:?}: {detail}"
6270 );
63− assert_eq!(out.edits.len(), 1);
71+ assert_eq!(out.edits.len(), has_edit_index.then(|| 1).unwrap_or(0));
6472 }
6573 }
6674
git-repository/tests/fixtures/make_fetch_repos.sh+2−1
@@ -10,7 +10,8 @@ git clone --shared base clone-as-base-with-changes · 9 unmodified lines
1010 git tag -m "new-file introduction" v1.0
1111 )
1212
13−git clone --bare --shared base two-origins
13+git clone --shared base two-origins
1414 (cd two-origins
1515 git remote add changes-on-top-of-origin "$PWD/../clone-as-base-with-changes"
16+ git branch "not-currently-checked-out"
1617 )