Example #1
0
        public void ShouldReturnValueForAValidRef()
        {
            var connection = new StubConnection();
            var r = new Core.Ref(null, "ref", ObjectId.ZeroId);

            connection.RefsMap.Add("ref", r);

            Assert.AreEqual(r, connection.GetRef("ref"));
        }
        public void ShouldReturnValueForAValidRef()
        {
            var result = new PushResult();
            var r = new Core.Ref(null, "ref", ObjectId.ZeroId);

            result.AdvertisedRefs.Add("ref", r);

            Assert.AreEqual(r, result.GetAdvertisedRef("ref"));
        }
Example #3
0
 public void testPushResult()
 {
     RemoteRefUpdate rru = new RemoteRefUpdate(db, "2c349335b7f797072cf729c4f3bb0914ecb6dec9",
                                               "refs/heads/master", false, "refs/remotes/test/master", null);
     Core.Ref @ref = new Core.Ref(Core.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.IsNotNull(result.GetTrackingRefUpdate("refs/remotes/test/master"));
     Assert.IsNotNull(result.GetAdvertisedRef("refs/heads/master"));
     Assert.IsNotNull(result.GetRemoteUpdate("refs/heads/master"));
 }
Example #4
0
        public void testDeleteMaster()
        {
            string sn = "refs/heads/master";
            RefSpec rs = new RefSpec(":" + sn);
            Assert.IsFalse(rs.Force);
            Assert.IsFalse(rs.Wildcard);
            Assert.AreEqual(sn, rs.Destination);
            Assert.IsNull(rs.Source);
            Assert.AreEqual(":" + sn, rs.ToString());
            Assert.AreEqual(rs, new RefSpec(rs.ToString()));

            Core.Ref r = new Core.Ref(Core.Ref.Storage.Loose, sn, null);
            Assert.IsFalse(rs.MatchSource(r));
            Assert.IsTrue(rs.MatchDestination(r));
            Assert.AreSame(rs, rs.ExpandFromSource(r));

            r = new Core.Ref(Core.Ref.Storage.Loose, sn + "-and-more", null);
            Assert.IsFalse(rs.MatchSource(r));
            Assert.IsFalse(rs.MatchDestination(r));
        }
Example #5
0
        public void testForceRemotesOrigin()
        {
            string srcn = "refs/heads/*";
            string dstn = "refs/remotes/origin/*";
            RefSpec rs = new RefSpec("+" + srcn + ":" + dstn);
            Assert.IsTrue(rs.Force);
            Assert.IsTrue(rs.Wildcard);
            Assert.AreEqual(srcn, rs.Source);
            Assert.AreEqual(dstn, rs.Destination);
            Assert.AreEqual("+" + srcn + ":" + dstn, rs.ToString());
            Assert.AreEqual(rs, new RefSpec(rs.ToString()));

            Core.Ref r;
            RefSpec expanded;

            r = new Core.Ref(Core.Ref.Storage.Loose, "refs/heads/master", null);
            Assert.IsTrue(rs.MatchSource(r));
            Assert.IsFalse(rs.MatchDestination(r));
            expanded = rs.ExpandFromSource(r);
            Assert.AreNotSame(rs, expanded);
            Assert.IsTrue(expanded.Force);
            Assert.IsFalse(expanded.Wildcard);
            Assert.AreEqual(r.Name, expanded.Source);
            Assert.AreEqual("refs/remotes/origin/master", expanded.Destination);

            r = new Core.Ref(Core.Ref.Storage.Loose, "refs/remotes/origin/next", null);
            Assert.IsFalse(rs.MatchSource(r));
            Assert.IsTrue(rs.MatchDestination(r));

            r = new Core.Ref(Core.Ref.Storage.Loose, "refs/tags/v1.0", null);
            Assert.IsFalse(rs.MatchSource(r));
            Assert.IsFalse(rs.MatchDestination(r));
        }
Example #6
0
 public void testTrackingRefUpdateDisabled()
 {
     RemoteRefUpdate rru = new RemoteRefUpdate(db, "2c349335b7f797072cf729c4f3bb0914ecb6dec9", "refs/heads/master", false, null, null);
     Core.Ref @ref = new Core.Ref(Core.Ref.Storage.Loose, "refs/heads/master", ObjectId.FromString("ac7e7e44c1885efb472ad54a78327d66bfc4ecef"));
     refUpdates.Add(rru);
     advertisedRefs.Add(@ref);
     PushResult result = executePush();
     Assert.IsTrue(result.TrackingRefUpdates.Count == 0);
 }
Example #7
0
 public void testUpdateUnexpectedRemoteVsForce()
 {
     RemoteRefUpdate rru = new RemoteRefUpdate(db, "2c349335b7f797072cf729c4f3bb0914ecb6dec9",
                                   "refs/heads/master", true, null,
                                   ObjectId.FromString("0000000000000000000000000000000000000001"));
     Core.Ref @ref = new Core.Ref(Core.Ref.Storage.Loose, "refs/heads/master", ObjectId.FromString("ac7e7e44c1885efb472ad54a78327d66bfc4ecef"));
     testOneUpdateStatus(rru, @ref, RemoteRefUpdate.UpdateStatus.REJECTED_REMOTE_CHANGED, null);
 }
Example #8
0
 public void testUpdateUpToDate()
 {
     RemoteRefUpdate rru = new RemoteRefUpdate(db, "2c349335b7f797072cf729c4f3bb0914ecb6dec9", "refs/heads/master", false, null, null);
     Core.Ref @ref = new Core.Ref(Core.Ref.Storage.Loose, "refs/heads/master", ObjectId.FromString("2c349335b7f797072cf729c4f3bb0914ecb6dec9"));
     testOneUpdateStatus(rru, @ref, RemoteRefUpdate.UpdateStatus.UP_TO_DATE, null);
 }
Example #9
0
 public void testUpdateRejectedByConnection()
 {
     connectionUpdateStatus = RemoteRefUpdate.UpdateStatus.REJECTED_OTHER_REASON;
     RemoteRefUpdate rru = new RemoteRefUpdate(db, "2c349335b7f797072cf729c4f3bb0914ecb6dec9",
                                               "refs/heads/master", false, null, null);
     Core.Ref @ref = new Core.Ref(Core.Ref.Storage.Loose, "refs/heads/master", ObjectId.FromString("ac7e7e44c1885efb472ad54a78327d66bfc4ecef"));
     testOneUpdateStatus(rru, @ref, RemoteRefUpdate.UpdateStatus.REJECTED_OTHER_REASON, null);
 }
Example #10
0
 public void testUpdateNonFastForwardUnknownObject()
 {
     RemoteRefUpdate rru = new RemoteRefUpdate(db, "2c349335b7f797072cf729c4f3bb0914ecb6dec9",
                                               "refs/heads/master", false, null, null);
     Core.Ref @ref = new Core.Ref(Core.Ref.Storage.Loose, "refs/heads/master", ObjectId.FromString("0000000000000000000000000000000000000001"));
     testOneUpdateStatus(rru, @ref, RemoteRefUpdate.UpdateStatus.REJECTED_NONFASTFORWARD, null);
 }
Example #11
0
 public void testUpdateNonFastForwardForced()
 {
     RemoteRefUpdate rru = new RemoteRefUpdate(db, "ac7e7e44c1885efb472ad54a78327d66bfc4ecef",
                                   "refs/heads/master", true, null, null);
     Core.Ref @ref = new Core.Ref(Core.Ref.Storage.Loose, "refs/heads/master", ObjectId.FromString("2c349335b7f797072cf729c4f3bb0914ecb6dec9"));
     testOneUpdateStatus(rru, @ref, RemoteRefUpdate.UpdateStatus.OK, false);
 }
Example #12
0
 public void testUpdateMixedCases()
 {
     RemoteRefUpdate rruOk = new RemoteRefUpdate(db, null, "refs/heads/master", false, null, null);
     Core.Ref refToChange = new Core.Ref(Core.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);
 }
Example #13
0
 public void testTrackingRefUpdateOnReject()
 {
     RemoteRefUpdate rru = new RemoteRefUpdate(db, "ac7e7e44c1885efb472ad54a78327d66bfc4ecef", "refs/heads/master", false, null, null);
     Core.Ref @ref = new Core.Ref(Core.Ref.Storage.Loose, "refs/heads/master", ObjectId.FromString("2c349335b7f797072cf729c4f3bb0914ecb6dec9"));
     PushResult result = testOneUpdateStatus(rru, @ref, RemoteRefUpdate.UpdateStatus.REJECTED_NONFASTFORWARD, null);
     Assert.IsTrue(result.TrackingRefUpdates.Count == 0);
 }