Skip to content

Commit

Permalink
Merge pull request #3 from prushton2/tests
Browse files Browse the repository at this point in the history
Tests
  • Loading branch information
prushton2 authored Dec 31, 2023
2 parents ade9cfb + 183f3b2 commit cb6c65c
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 10 deletions.
3 changes: 3 additions & 0 deletions src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ scb
init
initializes the build tool by creating the file scb. Add this to your gitignore
remove
removes the scb file
file
Manages files the build tool should keep track of
Arguments
Expand Down
49 changes: 39 additions & 10 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,40 @@ mod tests {
}


//the only array config option is files, so no need for a loop here
//the only array config option is files
//just append, check, remove, check
#[test]
#[serial]
fn test_arr_config() {

commands::init();
let files: &[String; 2] = &[String::from("file1"), String::from("file2")];
let test_keys: [&str; 1] = ["files"];
let test_array: &[String; 3] = &[String::from("file1"), String::from("file2"), String::from("string!")];

commands::arr_config("files", "-a", files);
let mut config: file::Config = file::load_config(commands::FILE_NAME).unwrap();
for i in test_keys {

assert_eq!(config.files[0], files[0]);
assert_eq!(config.files[1], files[1]);

commands::arr_config("files", "-r", files);
config = file::load_config(commands::FILE_NAME).unwrap();
commands::arr_config(i, "-a", test_array);
let mut config: file::Config = file::load_config(commands::FILE_NAME).unwrap();

match i {
"files" => {
assert_eq!(config.files[0], test_array[0]);
assert_eq!(config.files[1], test_array[1]);
assert_eq!(config.files[2], test_array[2]);
},
&_ => {}
}

assert_eq!(config.files.len(), 0);
commands::arr_config(i, "-r", test_array);
config = file::load_config(commands::FILE_NAME).unwrap();

match i {
"files" => {
assert_eq!(config.files.len(), 0);
},
&_ => {}
}
}

commands::remove();
}
Expand Down Expand Up @@ -73,4 +88,18 @@ mod tests {
commands::remove();

}

#[test]
#[serial]
fn test_build() {

commands::init();
commands::arr_config("files", "-a", &[String::from("main.c")]);

let result = commands::build("");
assert!(result.is_ok());

commands::remove();

}
}

0 comments on commit cb6c65c

Please sign in to comment.