diff --git a/.github/workflows/rust-ci.yml b/.github/workflows/rust-ci.yml new file mode 100755 index 0000000..8d6d602 --- /dev/null +++ b/.github/workflows/rust-ci.yml @@ -0,0 +1,31 @@ +name: Rust CI + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Setup Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + - name: Check + uses: actions-rs/cargo@v1 + with: + command: check + - name: Test + uses: actions-rs/cargo@v1 + with: + command: test \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index c148b5c..e2f06b5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -394,3 +394,16 @@ fn main() { println!(" {:.1} {} of space taken by duplicates", val, suffix); } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_hash_file() { + let path = PathBuf::from("test_file.txt"); + let (tx, _rx) = channel(); + hash_file(false, 1024, path, tx); // This will fail if the file does not exist or cannot be read + } + +} \ No newline at end of file