diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2024-09-04 11:32:05 +0100 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2024-09-04 14:23:54 +0100 |
| commit | 771f944af447c202eba045936a36dee71ab797ac (patch) | |
| tree | e691de4ebc8dde7ac4855e139881ff923bc254ce /src/bin/ngit/sub_commands/fetch.rs | |
| parent | 949c6459aa7683453a7160423b689ceadb08954b (diff) | |
refactor: fix imports, etc based on restructure
move some functions out of ngit and into lib/mod
and lib/git_events
remove MockConnect from binaries so it is only used in the library.
this was done:
* mainly because automocks were not being imported from
lib into each binary
* but also because the these functions were being
tested with MockConnect
Diffstat (limited to 'src/bin/ngit/sub_commands/fetch.rs')
| -rw-r--r-- | src/bin/ngit/sub_commands/fetch.rs | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/src/bin/ngit/sub_commands/fetch.rs b/src/bin/ngit/sub_commands/fetch.rs index b1e83c5..c69f1c5 100644 --- a/src/bin/ngit/sub_commands/fetch.rs +++ b/src/bin/ngit/sub_commands/fetch.rs | |||
| @@ -4,13 +4,9 @@ use anyhow::{Context, Result}; | |||
| 4 | use clap; | 4 | use clap; |
| 5 | use nostr::nips::nip01::Coordinate; | 5 | use nostr::nips::nip01::Coordinate; |
| 6 | 6 | ||
| 7 | #[cfg(not(test))] | ||
| 8 | use crate::client::Client; | ||
| 9 | #[cfg(test)] | ||
| 10 | use crate::client::MockConnect; | ||
| 11 | use crate::{ | 7 | use crate::{ |
| 12 | cli::Cli, | 8 | cli::Cli, |
| 13 | client::{fetching_with_report, Connect}, | 9 | client::{fetching_with_report, Client, Connect}, |
| 14 | git::{Repo, RepoActions}, | 10 | git::{Repo, RepoActions}, |
| 15 | repo_ref::get_repo_coordinates, | 11 | repo_ref::get_repo_coordinates, |
| 16 | }; | 12 | }; |
| @@ -25,10 +21,7 @@ pub struct SubCommandArgs { | |||
| 25 | pub async fn launch(args: &Cli, command_args: &SubCommandArgs) -> Result<()> { | 21 | pub async fn launch(args: &Cli, command_args: &SubCommandArgs) -> Result<()> { |
| 26 | let _ = args; | 22 | let _ = args; |
| 27 | let git_repo = Repo::discover().context("cannot find a git repository")?; | 23 | let git_repo = Repo::discover().context("cannot find a git repository")?; |
| 28 | #[cfg(not(test))] | ||
| 29 | let client = Client::default(); | 24 | let client = Client::default(); |
| 30 | #[cfg(test)] | ||
| 31 | let client = <MockConnect as std::default::Default>::default(); | ||
| 32 | let repo_coordinates = if command_args.repo.is_empty() { | 25 | let repo_coordinates = if command_args.repo.is_empty() { |
| 33 | get_repo_coordinates(&git_repo, &client).await? | 26 | get_repo_coordinates(&git_repo, &client).await? |
| 34 | } else { | 27 | } else { |