public void testPushResult() { RemoteRefUpdate rru = new RemoteRefUpdate(db, "2c349335b7f797072cf729c4f3bb0914ecb6dec9", "refs/heads/master", false, "refs/remotes/test/master", null); Ref @ref = new Ref(Ref.Storage.Loose, "refs/heads/master", ObjectId.FromString("ac7e7e44c1885efb472ad54a78327d66bfc4ecef")); refUpdates.Add(rru); advertisedRefs.Add(@ref); PushResult result = executePush(); Assert.AreEqual(1, result.TrackingRefUpdates.Count); Assert.AreEqual(1, result.AdvertisedRefs.Count); Assert.AreEqual(1, result.RemoteUpdates.Count); Assert.AreNotEqual(null, result.GetTrackingRefUpdate("refs/remotes/test/master")); Assert.AreNotEqual(null, result.GetAdvertisedRef("refs/heads/master")); Assert.AreNotEqual(null, result.GetRemoteUpdate("refs/heads/master")); }
public void testTrackingRefUpdateDisabled() { RemoteRefUpdate rru = new RemoteRefUpdate(db, "2c349335b7f797072cf729c4f3bb0914ecb6dec9", "refs/heads/master", false, null, null); Ref @ref = new Ref(Ref.Storage.Loose, "refs/heads/master", ObjectId.FromString("ac7e7e44c1885efb472ad54a78327d66bfc4ecef")); refUpdates.Add(rru); advertisedRefs.Add(@ref); PushResult result = executePush(); Assert.IsTrue(result.TrackingRefUpdates.Count == 0); }
public void testUpdateUpToDate() { RemoteRefUpdate rru = new RemoteRefUpdate(db, "2c349335b7f797072cf729c4f3bb0914ecb6dec9", "refs/heads/master", false, null, null); Ref @ref = new Ref(Ref.Storage.Loose, "refs/heads/master", ObjectId.FromString("2c349335b7f797072cf729c4f3bb0914ecb6dec9")); testOneUpdateStatus(rru, @ref, RemoteRefUpdate.UpdateStatus.UP_TO_DATE, false, false); }
private PushResult testOneUpdateStatus(RemoteRefUpdate rru, Ref advertisedRef, RemoteRefUpdate.UpdateStatus expectedStatus, bool checkFastForward, bool fastForward) { refUpdates.Add(rru); if (advertisedRef != null) advertisedRefs.Add(advertisedRef); PushResult result = executePush(); Assert.AreEqual(expectedStatus, rru.Status); if (checkFastForward) Assert.AreEqual(fastForward, rru.FastForward); return result; }
public void testUpdateRejectedByConnection() { connectionUpdateStatus = RemoteRefUpdate.UpdateStatus.REJECTED_OTHER_REASON; RemoteRefUpdate rru = new RemoteRefUpdate(db, "2c349335b7f797072cf729c4f3bb0914ecb6dec9", "refs/heads/master", false, null, null); Ref @ref = new Ref(Ref.Storage.Loose, "refs/heads/master", ObjectId.FromString("ac7e7e44c1885efb472ad54a78327d66bfc4ecef")); testOneUpdateStatus(rru, @ref, RemoteRefUpdate.UpdateStatus.REJECTED_OTHER_REASON, false, false); }
public void testUpdateUnexpectedRemoteVsForce() { RemoteRefUpdate rru = new RemoteRefUpdate(db, "2c349335b7f797072cf729c4f3bb0914ecb6dec9", "refs/heads/master", true, null, ObjectId.FromString("0000000000000000000000000000000000000001")); Ref @ref = new Ref(Ref.Storage.Loose, "refs/heads/master", ObjectId.FromString("ac7e7e44c1885efb472ad54a78327d66bfc4ecef")); testOneUpdateStatus(rru, @ref, RemoteRefUpdate.UpdateStatus.REJECTED_REMOTE_CHANGED, false, false); }
public void testUpdateNonFastForwardForced() { RemoteRefUpdate rru = new RemoteRefUpdate(db, "ac7e7e44c1885efb472ad54a78327d66bfc4ecef", "refs/heads/master", true, null, null); Ref @ref = new Ref(Ref.Storage.Loose, "refs/heads/master", ObjectId.FromString("2c349335b7f797072cf729c4f3bb0914ecb6dec9")); testOneUpdateStatus(rru, @ref, RemoteRefUpdate.UpdateStatus.OK, true, false); }
public void testUpdateNonFastForwardUnknownObject() { RemoteRefUpdate rru = new RemoteRefUpdate(db, "2c349335b7f797072cf729c4f3bb0914ecb6dec9", "refs/heads/master", false, null, null); Ref @ref = new Ref(Ref.Storage.Loose, "refs/heads/master", ObjectId.FromString("0000000000000000000000000000000000000001")); testOneUpdateStatus(rru, @ref, RemoteRefUpdate.UpdateStatus.REJECTED_NONFASTFORWARD, false, false); }
public void testUpdateMixedCases() { RemoteRefUpdate rruOk = new RemoteRefUpdate(db, null, "refs/heads/master", false, null, null); Ref refToChange = new Ref(Ref.Storage.Loose, "refs/heads/master", ObjectId.FromString("2c349335b7f797072cf729c4f3bb0914ecb6dec9")); RemoteRefUpdate rruReject = new RemoteRefUpdate(db, null, "refs/heads/nonexisting", false, null, null); refUpdates.Add(rruOk); refUpdates.Add(rruReject); advertisedRefs.Add(refToChange); executePush(); Assert.AreEqual(RemoteRefUpdate.UpdateStatus.OK, rruOk.Status); Assert.AreEqual(true, rruOk.FastForward); Assert.AreEqual(RemoteRefUpdate.UpdateStatus.NON_EXISTING, rruReject.Status); }
public void testUpdateDeleteNonExisting() { RemoteRefUpdate rru = new RemoteRefUpdate(db, null, "refs/heads/master", false, null, null); testOneUpdateStatus(rru, null, RemoteRefUpdate.UpdateStatus.NON_EXISTING, false, false); }
public void testUpdateCreateRef() { RemoteRefUpdate rru = new RemoteRefUpdate(db, "ac7e7e44c1885efb472ad54a78327d66bfc4ecef", "refs/heads/master", false, null, null); testOneUpdateStatus(rru, null, RemoteRefUpdate.UpdateStatus.OK, true, true); }
public void testTrackingRefUpdateOnReject() { RemoteRefUpdate rru = new RemoteRefUpdate(db, "ac7e7e44c1885efb472ad54a78327d66bfc4ecef", "refs/heads/master", false, null, null); Ref @ref = new Ref(Ref.Storage.Loose, "refs/heads/master", ObjectId.FromString("2c349335b7f797072cf729c4f3bb0914ecb6dec9")); PushResult result = testOneUpdateStatus(rru, @ref, RemoteRefUpdate.UpdateStatus.REJECTED_NONFASTFORWARD, false, false); Assert.IsTrue(result.TrackingRefUpdates.Count == 0); }
public RemoteRefUpdate(RemoteRefUpdate baseUpdate, ObjectId newExpectedOldObjectId) : this(baseUpdate.localDb, baseUpdate.SourceRef, baseUpdate.RemoteName, baseUpdate.ForceUpdate, (baseUpdate.TrackingRefUpdate == null ? null : baseUpdate.TrackingRefUpdate.LocalName), newExpectedOldObjectId) { }