Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
arlyon committed Apr 27, 2023
1 parent 71dd1c7 commit 0ead7aa
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
2 changes: 1 addition & 1 deletion crates/globwatch/Cargo.toml
Expand Up @@ -19,7 +19,7 @@ pin-project = "1.0.12"
stop-token = "0.7.0"
tokio = { version = "1.25.0", features = ["sync"] }
tokio-stream = "0.1.12"
tracing = "0.1.37"
tracing.workspace = true
unic-segment = "0.9.0"
walkdir = "2.3.2"

Expand Down
17 changes: 17 additions & 0 deletions crates/turborepo-lib/src/commands/mod.rs
Expand Up @@ -169,6 +169,7 @@ mod test {

use crate::get_version;

#[cfg(not(target_os = "windows"))]
#[test_case("/tmp/turborepo", "6e0cfa616f75a61c"; "basic example")]
fn test_repo_hash(path: &str, expected_hash: &str) {
use super::CommandBase;
Expand All @@ -183,4 +184,20 @@ mod test {
assert_eq!(hash, expected_hash);
assert_eq!(hash.len(), 16);
}

#[cfg(target_os = "windows")]
#[test_case("C:\\\\tmp\\turborepo", "6e0cfa616f75a61c"; "basic example")]
fn test_repo_hash_win(path: &str, expected_hash: &str) {
use super::CommandBase;
use crate::Args;

let args = Args::default();
let repo_root = AbsoluteSystemPathBuf::new(path).unwrap();
let command_base = CommandBase::new(args, repo_root, get_version()).unwrap();

let hash = command_base.repo_hash();

assert_eq!(hash, expected_hash);
assert_eq!(hash.len(), 16);
}
}
16 changes: 14 additions & 2 deletions crates/turborepo-lib/src/config/repo.rs
Expand Up @@ -189,7 +189,13 @@ mod test {

#[test]
fn test_repo_config_when_missing() -> Result<()> {
let config = RepoConfigLoader::new(PathBuf::from("missing")).load();
let path = if cfg!(windows) {
"C:\\missing"
} else {
"/missing"
};

let config = RepoConfigLoader::new(AbsoluteSystemPathBuf::new(path).unwrap()).load();
assert!(config.is_ok());

Ok(())
Expand All @@ -215,7 +221,13 @@ mod test {

#[test]
fn test_repo_config_includes_defaults() {
let config = RepoConfigLoader::new(PathBuf::from("missing"))
let path = if cfg!(windows) {
"C:\\missing"
} else {
"/missing"
};

let config = RepoConfigLoader::new(AbsoluteSystemPathBuf::new(path).unwrap())
.load()
.unwrap();
assert_eq!(config.api_url(), DEFAULT_API_URL);
Expand Down

0 comments on commit 0ead7aa

Please sign in to comment.