test(ocaml): test custom switch indicators (#2657)
This commit is contained in:
parent
c60ddf76f6
commit
dead06ba14
|
@ -174,7 +174,7 @@ mod tests {
|
|||
File::create(dir.path().join("package.json"))?.sync_all()?;
|
||||
fs::write(
|
||||
dir.path().join("package.lock"),
|
||||
"{\"dependencies\": {\"ocaml\": \"4.8.1000\"}}",
|
||||
r#"{"dependencies": {"ocaml": "4.8.1000"}}"#,
|
||||
)?;
|
||||
let actual = ModuleRenderer::new("ocaml").path(dir.path()).collect();
|
||||
let expected = Some(format!(
|
||||
|
@ -356,6 +356,35 @@ mod tests {
|
|||
dir.close()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn with_global_opam_switch_custom_indicator() -> io::Result<()> {
|
||||
let dir = tempfile::tempdir()?;
|
||||
File::create(dir.path().join("any.ml"))?.sync_all()?;
|
||||
|
||||
let actual = ModuleRenderer::new("ocaml")
|
||||
.config(toml::toml! {
|
||||
[ocaml]
|
||||
global_switch_indicator = "g/"
|
||||
})
|
||||
.cmd(
|
||||
"opam switch show --safe",
|
||||
Some(CommandOutput {
|
||||
stdout: String::from("ocaml-base-compiler.4.10.0\n"),
|
||||
stderr: String::default(),
|
||||
}),
|
||||
)
|
||||
.path(dir.path())
|
||||
.collect();
|
||||
let expected = Some(format!(
|
||||
"via {}",
|
||||
Color::Yellow
|
||||
.bold()
|
||||
.paint("🐫 v4.10.0 (g/ocaml-base-compiler.4.10.0) ")
|
||||
));
|
||||
assert_eq!(expected, actual);
|
||||
dir.close()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn with_local_opam_switch() -> io::Result<()> {
|
||||
let dir = tempfile::tempdir()?;
|
||||
|
@ -378,4 +407,31 @@ mod tests {
|
|||
assert_eq!(expected, actual);
|
||||
dir.close()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn with_local_opam_switch_custom_indicator() -> io::Result<()> {
|
||||
let dir = tempfile::tempdir()?;
|
||||
File::create(dir.path().join("any.ml"))?.sync_all()?;
|
||||
|
||||
let actual = ModuleRenderer::new("ocaml")
|
||||
.config(toml::toml! {
|
||||
[ocaml]
|
||||
local_switch_indicator = "^"
|
||||
})
|
||||
.cmd(
|
||||
"opam switch show --safe",
|
||||
Some(CommandOutput {
|
||||
stdout: String::from("/path/to/my-project\n"),
|
||||
stderr: String::default(),
|
||||
}),
|
||||
)
|
||||
.path(dir.path())
|
||||
.collect();
|
||||
let expected = Some(format!(
|
||||
"via {}",
|
||||
Color::Yellow.bold().paint("🐫 v4.10.0 (^my-project) ")
|
||||
));
|
||||
assert_eq!(expected, actual);
|
||||
dir.close()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue