diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2024-08-08 14:58:29 +0100 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2024-08-08 15:01:32 +0100 |
| commit | b53251925e8cf0393377633ec1012f0613e7c42b (patch) | |
| tree | a9749e054547266bf68d798dae9d31aed03d009a /test_utils | |
| parent | 918a3d99aa84727b0bf84d83cc6b0125b3c301cd (diff) | |
test(remote): `push` to existing proposal
push 2 commits to an existing proposal
there are a lot of asserts in here but if they were split out into
their own tests the suite would take much longer to run as we are
waiting a few seconds in the test to ensure the
timestamps are different
Diffstat (limited to 'test_utils')
| -rw-r--r-- | test_utils/src/git.rs | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/test_utils/src/git.rs b/test_utils/src/git.rs index f299b40..5ae7f39 100644 --- a/test_utils/src/git.rs +++ b/test_utils/src/git.rs | |||
| @@ -8,7 +8,7 @@ use std::{ | |||
| 8 | }; | 8 | }; |
| 9 | 9 | ||
| 10 | use anyhow::{Context, Result}; | 10 | use anyhow::{Context, Result}; |
| 11 | use git2::{Oid, RepositoryInitOptions, Signature, Time}; | 11 | use git2::{Branch, Oid, RepositoryInitOptions, Signature, Time}; |
| 12 | use nostr::nips::nip01::Coordinate; | 12 | use nostr::nips::nip01::Coordinate; |
| 13 | use nostr_sdk::{Kind, ToBech32}; | 13 | use nostr_sdk::{Kind, ToBech32}; |
| 14 | 14 | ||
| @@ -214,10 +214,10 @@ impl GitTestRepo { | |||
| 214 | Ok(oid) | 214 | Ok(oid) |
| 215 | } | 215 | } |
| 216 | 216 | ||
| 217 | pub fn create_branch(&self, branch_name: &str) -> Result<()> { | 217 | pub fn create_branch(&self, branch_name: &str) -> Result<Branch> { |
| 218 | self.git_repo | 218 | self.git_repo |
| 219 | .branch(branch_name, &self.git_repo.head()?.peel_to_commit()?, false)?; | 219 | .branch(branch_name, &self.git_repo.head()?.peel_to_commit()?, false) |
| 220 | Ok(()) | 220 | .context("could not create branch") |
| 221 | } | 221 | } |
| 222 | 222 | ||
| 223 | pub fn checkout(&self, ref_name: &str) -> Result<Oid> { | 223 | pub fn checkout(&self, ref_name: &str) -> Result<Oid> { |
| @@ -273,6 +273,14 @@ impl GitTestRepo { | |||
| 273 | self.git_repo.remote(name, url)?; | 273 | self.git_repo.remote(name, url)?; |
| 274 | Ok(()) | 274 | Ok(()) |
| 275 | } | 275 | } |
| 276 | |||
| 277 | pub fn checkout_remote_branch(&self, branch_name: &str) -> Result<()> { | ||
| 278 | self.checkout(&format!("remotes/origin/{branch_name}"))?; | ||
| 279 | let mut branch = self.create_branch(branch_name)?; | ||
| 280 | branch.set_upstream(Some(&format!("origin/{branch_name}")))?; | ||
| 281 | self.checkout(branch_name)?; | ||
| 282 | Ok(()) | ||
| 283 | } | ||
| 276 | } | 284 | } |
| 277 | 285 | ||
| 278 | impl Drop for GitTestRepo { | 286 | impl Drop for GitTestRepo { |