diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index bf36790..c489279 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -18,9 +18,8 @@ jobs: run: brew install dbus - name: Build run: cargo build --verbose --bin cli_app - - name: Run CLI - run: cargo run --bin cli_app - + - name: test + run: cargo test build-windows: runs-on: windows-latest @@ -30,16 +29,16 @@ jobs: run: choco install dbus -y - name: Build run: cargo build --verbose --bin cli_app - - name: Run CLI - run: cargo run --bin cli_app + - name: test + run: cargo test build-linux: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Install Dependencies - run: sudo apt update && sudo apt install -y libdbus-1-dev libhidapi-dev + run: sudo apt update && sudo apt install -y libdbus-1-dev libhidapi-dev libusb-1.0-0-dev - name: Build run: cargo build --verbose - - name: Run CLI - run: cargo run --bin cli_app \ No newline at end of file + - name: test + run: cargo test \ No newline at end of file diff --git a/src/bin/cli_app.rs b/src/bin/cli_app.rs index 48cf640..265190c 100644 --- a/src/bin/cli_app.rs +++ b/src/bin/cli_app.rs @@ -16,4 +16,13 @@ fn main() { } }; println!("Battery level: {}%", battery_level); +} + +#[test] +fn test_basic_device_access() { + let mut device = match Device::new() { + Ok(device) => device, + Err(error) => return + }; + device.update_battery_level(); } \ No newline at end of file