Skip to content

Commit

Permalink
test: added reset() to more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed May 30, 2024
1 parent 783298c commit 1c76011
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/shell/fish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,36 +126,42 @@ impl Shell for Fish {
#[cfg(test)]
mod tests {
use insta::assert_snapshot;
use test_log::test;

use crate::test::replace_path;
use crate::test::{replace_path, reset};

use super::*;

#[test]
fn test_activate() {
reset();
let fish = Fish::default();
let exe = Path::new("/some/dir/mise");
assert_snapshot!(fish.activate(exe, " --status".into()));
}

#[test]
fn test_set_env() {
reset();
assert_snapshot!(Fish::default().set_env("FOO", "1"));
}

#[test]
fn test_prepend_env() {
reset();
let sh = Fish::default();
assert_snapshot!(replace_path(&sh.prepend_env("PATH", "/some/dir:/2/dir")));
}

#[test]
fn test_unset_env() {
reset();
assert_snapshot!(Fish::default().unset_env("FOO"));
}

#[test]
fn test_deactivate() {
reset();
let deactivate = Fish::default().deactivate();
assert_snapshot!(replace_path(&deactivate));
}
Expand Down
8 changes: 7 additions & 1 deletion src/shell/zsh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,36 +104,42 @@ impl Shell for Zsh {
#[cfg(test)]
mod tests {
use insta::assert_snapshot;
use test_log::test;

use crate::test::replace_path;
use crate::test::{replace_path, reset};

use super::*;

#[test]
fn test_activate() {
reset();
let zsh = Zsh::default();
let exe = Path::new("/some/dir/mise");
assert_snapshot!(zsh.activate(exe, " --status".into()));
}

#[test]
fn test_set_env() {
reset();
assert_snapshot!(Zsh::default().set_env("FOO", "1"));
}

#[test]
fn test_prepend_env() {
reset();
let sh = Bash::default();
assert_snapshot!(replace_path(&sh.prepend_env("PATH", "/some/dir:/2/dir")));
}

#[test]
fn test_unset_env() {
reset();
assert_snapshot!(Zsh::default().unset_env("FOO"));
}

#[test]
fn test_deactivate() {
reset();
let deactivate = Zsh::default().deactivate();
assert_snapshot!(replace_path(&deactivate));
}
Expand Down

0 comments on commit 1c76011

Please sign in to comment.