Skip to content

Commit f261d22

Browse files
committed
Remove redundant test function
1 parent f71106e commit f261d22

File tree

4 files changed

+10
-27
lines changed

4 files changed

+10
-27
lines changed

tests/cli_apply_subcommand_tests.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ mod utils;
33
use std::fs;
44
use std::path::Path;
55

6-
use crate::utils::{
7-
read_file_to_string, setup, write_to_file, CURRENT_SCHEME_FILE_NAME, REPO_NAME,
8-
};
6+
use crate::utils::{setup, write_to_file, CURRENT_SCHEME_FILE_NAME, REPO_NAME};
97
use anyhow::Result;
108

119
#[test]
@@ -38,7 +36,7 @@ fn test_cli_apply_subcommand_with_setup() -> Result<()> {
3836
data_path.join(shell_theme_filename).exists(),
3937
"Path does not exist"
4038
);
41-
assert_eq!(read_file_to_string(&current_scheme_path)?, scheme_name);
39+
assert_eq!(fs::read_to_string(&current_scheme_path)?, scheme_name);
4240

4341
cleanup()?;
4442
Ok(())

tests/cli_general_tests.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
mod utils;
22

33
use crate::utils::{
4-
cleanup, read_file_to_string, setup, write_to_file, COMMAND_NAME, CURRENT_SCHEME_FILE_NAME,
5-
ORG_NAME, REPO_NAME,
4+
cleanup, setup, write_to_file, COMMAND_NAME, CURRENT_SCHEME_FILE_NAME, ORG_NAME, REPO_NAME,
65
};
76
use anyhow::Result;
87
use std::{fs, path::PathBuf};
@@ -121,7 +120,7 @@ fn test_cli_default_data_path() -> Result<()> {
121120

122121
// This test is important to determine the config.toml is being read correctly
123122
assert_eq!(
124-
read_file_to_string(&current_scheme_file_path)?,
123+
fs::read_to_string(&current_scheme_file_path)?,
125124
init_scheme_name
126125
);
127126

@@ -138,7 +137,7 @@ fn test_cli_default_data_path() -> Result<()> {
138137
"stdout does not contain the expected output"
139138
);
140139
assert_eq!(
141-
read_file_to_string(&data_path.join(CURRENT_SCHEME_FILE_NAME))?,
140+
fs::read_to_string(data_path.join(CURRENT_SCHEME_FILE_NAME))?,
142141
scheme_name
143142
);
144143
assert!(

tests/cli_init_subcommand_tests.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
mod utils;
22

3-
use crate::utils::{
4-
read_file_to_string, setup, write_to_file, CURRENT_SCHEME_FILE_NAME, REPO_NAME,
5-
};
3+
use std::fs;
4+
5+
use crate::utils::{setup, write_to_file, CURRENT_SCHEME_FILE_NAME, REPO_NAME};
66
use anyhow::Result;
77

88
#[test]
@@ -79,7 +79,7 @@ fn test_cli_init_subcommand_with_config_default_scheme() -> Result<()> {
7979
// ------
8080
// Assert
8181
// ------
82-
let expected_scheme_name = read_file_to_string(&data_path.join(CURRENT_SCHEME_FILE_NAME))?;
82+
let expected_scheme_name = fs::read_to_string(data_path.join(CURRENT_SCHEME_FILE_NAME))?;
8383
assert!(
8484
stdout.is_empty(),
8585
"stdout does not contain the expected output"

tests/utils.rs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use anyhow::{anyhow, Result};
22
use std::error::Error;
33
use std::fs::{self, File};
4-
use std::io::{Read, Write};
4+
use std::io::Write;
55
use std::path::{Path, PathBuf};
66
use std::process::Command;
77
use std::str;
@@ -79,20 +79,6 @@ pub fn write_to_file(path: &Path, contents: &str) -> Result<()> {
7979
Ok(())
8080
}
8181

82-
#[allow(dead_code)]
83-
pub fn read_file_to_string(path: &Path) -> Result<String> {
84-
if !path.exists() {
85-
return Err(anyhow!("File does not exist: {}", path.display()));
86-
}
87-
88-
let mut file = File::open(path)?;
89-
let mut contents = String::new();
90-
91-
file.read_to_string(&mut contents)?;
92-
93-
Ok(contents)
94-
}
95-
9682
#[allow(clippy::type_complexity)]
9783
pub fn setup(
9884
name: &str,

0 commit comments

Comments
 (0)