Skip to content

Commit

Permalink
run the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
morgante committed Oct 8, 2024
1 parent b8013c2 commit c8e7004
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion crates/gritmodule/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::{
path::{Path, PathBuf},
vec::Vec,
};
use std::{env, fmt, io::ErrorKind, str::FromStr};
use std::{env, fmt, io::ErrorKind};
use tokio::{fs, io::AsyncWriteExt};
use tracing::instrument;

Expand Down
2 changes: 1 addition & 1 deletion crates/gritmodule/src/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ pub async fn find_and_resolve_grit_dir(
};

match existing_config {
Some(config) => get_grit_files_from_known_grit_dir(&PathBuf::from(config), vec![]).await,
Some(config) => get_grit_files_from_known_grit_dir(&config, vec![]).await,
None => match global_dir {
Some(global_dir) => {
let stdlib_modules = get_stdlib_modules();
Expand Down
15 changes: 10 additions & 5 deletions crates/gritmodule/src/searcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use ignore::Walk;
use std::borrow::Cow;
use std::path::Path;
use std::path::PathBuf;
use std::str::FromStr;

use tokio::fs;

use crate::markdown::GritDefinitionOverrides;
Expand Down Expand Up @@ -241,7 +241,6 @@ pub async fn find_repo_root_from(dir: PathBuf) -> Result<Option<String>> {
pub async fn find_grit_modules_dir(dir: PathBuf) -> Result<PathBuf> {
let grit_dir = find_grit_dir_from(dir).await;
if let Some(grit_dir) = grit_dir {
let grit_dir = PathBuf::from(grit_dir);
let grit_modules_dir = grit_dir.join(GRIT_MODULE_DIR);
if grit_modules_dir.exists() {
return Ok(grit_modules_dir);
Expand Down Expand Up @@ -283,15 +282,21 @@ mod tests {
let config_file = find_grit_dir_from(PathBuf::from("fixtures/searcher/dir/nested"))
.await
.unwrap();
assert_eq!(config_file, "fixtures/searcher/dir/nested/.grit");
assert_eq!(
config_file,
PathBuf::from("fixtures/searcher/dir/nested/.grit")
);
}

#[tokio::test]
async fn finds_config_dir_in_parent_directory() {
let config_file = find_grit_dir_from(PathBuf::from("fixtures/searcher/another/nested"))
.await
.unwrap();
assert_eq!(config_file, "fixtures/searcher/another/.grit");
assert_eq!(
config_file,
PathBuf::from("fixtures/searcher/another/.grit")
);
}

#[tokio::test]
Expand Down Expand Up @@ -326,6 +331,6 @@ mod tests {
Repository::clone(&remote, temp_dir.path()).unwrap();
let config_file = find_grit_dir_from(temp_dir.path().into()).await;
let exp_grit = temp_dir.path().join(".grit");
assert_eq!(config_file.unwrap(), exp_grit.to_str().unwrap());
assert_eq!(config_file.unwrap(), exp_grit);
}
}

0 comments on commit c8e7004

Please sign in to comment.