diff options
author | Dave Borowitz <dborowitz@google.com> | 2015-07-10 17:12:54 -0700 |
---|---|---|
committer | Dave Borowitz <dborowitz@google.com> | 2015-07-13 08:30:11 -0700 |
commit | f946ed1d97ee552e9701a0fbbf952421a107c943 (patch) | |
tree | f7d64ef7fc04290f013545e18c471e3f8181e2b1 /org.eclipse.jgit.test | |
parent | b4ecb88367a00b0ed864c0f5a9ddb4d438c27879 (diff) | |
download | jgit-f946ed1d97ee552e9701a0fbbf952421a107c943.tar.gz jgit-f946ed1d97ee552e9701a0fbbf952421a107c943.zip |
PushCertificateStore: Add method to save in batch
Change-Id: I8bfaee1a52d368ffe2cd7e8af1754a5261569078
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateStoreTest.java | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateStoreTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateStoreTest.java index d2faaa7742..77a0708e1b 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateStoreTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateStoreTest.java @@ -60,7 +60,9 @@ import java.util.concurrent.atomic.AtomicInteger; import org.eclipse.jgit.internal.storage.dfs.DfsRepositoryDescription; import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository; +import org.eclipse.jgit.lib.BatchRefUpdate; import org.eclipse.jgit.lib.Constants; +import org.eclipse.jgit.lib.NullProgressMonitor; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.PersonIdent; import org.eclipse.jgit.revwalk.RevCommit; @@ -271,6 +273,26 @@ public class PushCertificateStoreTest { assertCerts(store2, "refs/heads/branch", addBranch); } + @Test + public void saveInBatch() throws Exception { + BatchRefUpdate batch = repo.getRefDatabase().newBatchUpdate(); + PushCertificate addMaster = newCert( + command(zeroId(), ID1, "refs/heads/master")); + store.put(addMaster, newIdent()); + store.save(batch); + + List<ReceiveCommand> commands = batch.getCommands(); + assertEquals(1, commands.size()); + ReceiveCommand cmd = commands.get(0); + + try (RevWalk rw = new RevWalk(repo)) { + assertEquals("refs/meta/push-certs", cmd.getRefName()); + assertEquals(ReceiveCommand.Result.NOT_ATTEMPTED, cmd.getResult()); + batch.execute(rw, NullProgressMonitor.INSTANCE); + assertEquals(ReceiveCommand.Result.OK, cmd.getResult()); + } + } + private PersonIdent newIdent() { return new PersonIdent( "A U. Thor", "author@example.com", ts.getAndIncrement(), 0); |