Skip to content

Commit

Permalink
Merge pull request #849 from Raspirus/yaml-test
Browse files Browse the repository at this point in the history
Fix Rust testing Action
  • Loading branch information
Benji377 authored Sep 22, 2024
2 parents 8f2be37 + 2708d39 commit 9c5d7b1
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 8 deletions.
25 changes: 19 additions & 6 deletions .github/workflows/testproject.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test backend
name: Test project

on:
push:
Expand All @@ -9,19 +9,32 @@ on:

env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1

jobs:
build:
runs-on: ubuntu-latest
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y build-essential curl libssl-dev pkg-config

- name: Install Rust
run: rustup update stable

- name: Set up user environment on macOS
run: |
mkdir -p $HOME/Downloads
mkdir -p $HOME/Desktop
mkdir -p $HOME/Documents
echo "XDG_DOWNLOAD_DIR=$HOME/Downloads" >> $GITHUB_ENV
echo "XDG_DESKTOP_DIR=$HOME/Desktop" >> $GITHUB_ENV
echo "XDG_DOCUMENTS_DIR=$HOME/Documents" >> $GITHUB_ENV
echo "HOME_DIR set to $HOME"
ls -la $HOME # Verify the user directories
- name: Build
run: cargo build --verbose
run: cargo build --verbose --release

- name: Run tests
run: cargo test --workspace --verbose
run: cargo test --verbose --release
env:
IGNORE_PANICS: true
19 changes: 17 additions & 2 deletions src/tests/file_scanner_test.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#[cfg(test)]
mod tests {

#[test]
fn test_filescanner_invalid_path() {
use crate::backend::yara_scanner::YaraScanner;
Expand All @@ -24,13 +25,20 @@ mod tests {

#[test]
fn test_scan_file_found_none() {
use crate::backend::yara_scanner::YaraScanner;
use crate::backend::{downloader, yara_scanner::YaraScanner};
use iced::futures::channel::mpsc;
use std::{
path::Path,
sync::{Arc, Mutex},
};

let runtime = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap();
let update = runtime.block_on(downloader::update());
dbg!(&update);

std::fs::write(
Path::new("./clean"),
"Test content of a file with no particular malicious intent".to_owned(),
Expand All @@ -53,13 +61,20 @@ mod tests {

#[test]
fn test_scan_file_found_one() {
use crate::backend::yara_scanner::YaraScanner;
use crate::backend::{downloader, yara_scanner::YaraScanner};
use iced::futures::channel::mpsc;
use std::{
path::Path,
sync::{Arc, Mutex},
};

let runtime = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap();
let update = runtime.block_on(downloader::update());
dbg!(&update);

std::fs::write(
Path::new("./tag"),
"X5O!P%@AP[4\\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*".to_owned(),
Expand Down

0 comments on commit 9c5d7b1

Please sign in to comment.