message: test: More tests for path functions as well as minor fixes
diff: @@ -20,10 +20,11 @@ fn logger() -> slog::Logger {
  fn get_tests_bin_path() -> PathBuf {
  let path = current_dir().unwrap();
  - path.join("tests/bin")
  + path.join("tests")
  }
  #[test]
  +#[cfg(not(target_ = "wasm32"))]
  fn get_local_bin_path_should_return_a_path() {
  let crate_path = Path::new("");
  @@ -48,7 +49,7 @@ fn get_local_bin_path_should_return_with_exe_for_windows() {
  #[test]
  fn ensure_local_bin_dir_should_return_ok_for_folder_that_exists() {
  - let crate_path = get_tests_bin_path();
  + let crate_path = get_tests_bin_path().join("bin2");
  fs::create_dir_all(crate_path.to_owned()).unwrap();
  @@ -61,7 +62,7 @@ fn ensure_local_bin_dir_should_return_ok_for_folder_that_exists() {
  #[test]
  fn ensure_local_bin_dir_should_create_folder_if_it_doesnt_exist() {
  - let crate_path = get_tests_bin_path();
  + let crate_path = get_tests_bin_path().join("bin3");
  // Make sure that the folder doesn't exist
  // before we call ensure_local_bin_dir();
  @@ -76,4 +77,42 @@ fn ensure_local_bin_dir_should_create_folder_if_it_doesnt_exist() {
  // Make sure that the directory actually exists.
  let dir = fs::read_dir(crate_path.to_owned());
  assert!(dir.is_ok());
  +
  + fs::remove_dir_all(crate_path).unwrap();
  +}
  +
  +#[test]
  +fn bin_path_should_return_some_for_path_that_exists() {
  + let crate_path = get_tests_bin_path();
  + let bin_file = "wasm-bindgen";
  + let full_bin_path = crate_path.join("bin");
  + let path_with_bin_file = full_bin_path.join(bin_file);
  +
  + fs::create_dir_all(full_bin_path.to_owned()).unwrap();
  + fs::File::create(path_with_bin_file.to_owned()).unwrap();
  +
  + let result = bin_path(&logger(), &crate_path, bin_file);
  +
  + assert!(result.is_some());
  + assert_eq!(path_with_bin_file, result.unwrap());
  +
  + fs::remove_dir_all(full_bin_path).unwrap();
  +}
  +
  +#[test]
  +fn bin_path_should_return_none_for_path_that_does_not_exists() {
  + let crate_path = get_tests_bin_path();
  + let bin_file = "wasm-binfile";
  + let full_bin_path = crate_path.join("bin_path");
  + let path_with_bin_file = full_bin_path.join(bin_file);
  +
  + // Make sure that the folder doesn't exist
  + // before we call bin_path();
  + let file = fs::File::open(path_with_bin_file.to_owned());
  + let file_error = file.err().unwrap();
  + assert_eq!(file_error.kind(), io::ErrorKind::NotFound);
  +
  + let result = bin_path(&logger(), &crate_path, bin_file);
  +
  + assert!(result.is_none());
  }
  