Skip to content

Commit

Permalink
shift test data to include another scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
tompscanlan committed Aug 31, 2023
1 parent c7912e2 commit 199d18d
Show file tree
Hide file tree
Showing 13 changed files with 8 additions and 11 deletions.
4 changes: 2 additions & 2 deletions kondo-lib/src/lib_test.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#[cfg(test)]
mod test {
// use kondo_lib::{Project, ProjectType, ScanOptions};
use std::path::PathBuf;
use tempfile;

use crate::{Project, ProjectType, ScanOptions};

// Given test data, clean should remove some files
#[test]
fn test_clean() {
let scan_options: ScanOptions = ScanOptions {
Expand All @@ -14,7 +14,7 @@ mod test {
};

let tempdir = get_copy_of_test_data_as_temp_dir();
let path = tempdir.path().join("test_data/test_discover");
let path = tempdir.path().join("test_data/scenario_a");

// Given 2 py projects with content cached
let project_a = Project {
Expand Down
10 changes: 4 additions & 6 deletions kondo/src/main_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ mod test {
fn test_discover() {
// given a directory with two projects
let tempdir = get_copy_of_test_data_as_temp_dir();
let path = tempdir.path().join("test_data/test_discover");
let path = tempdir.path().join("test_data");

// and basic setup
let scan_options: ScanOptions = ScanOptions {
Expand All @@ -34,17 +34,16 @@ mod test {
count += 1;
}

// ought to find two projects
assert_eq!(count, 2);
// ought to find the right number of projects
assert_eq!(count, 3);

// clean up
tempdir.close().unwrap();
}


fn get_copy_of_test_data_as_temp_dir() -> tempfile::TempDir {
extern crate fs_extra;
let options = fs_extra::dir::CopyOptions::new();
let options = fs_extra::dir::CopyOptions::new();

let mut path: PathBuf = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
path.push("../test_data");
Expand All @@ -59,5 +58,4 @@ mod test {

return tmp_dir;
}

}
1 change: 1 addition & 0 deletions test_data/scenario_b/cargo-project-a/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# empty example is enough to signal this is a cargo project
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// This file represents cargo build artifacts
Empty file.
3 changes: 0 additions & 3 deletions x/test_data/test_discover/python-project-b/main.py

This file was deleted.

0 comments on commit 199d18d

Please sign in to comment.