From 6f9678e8f772bcf643e75b2e0bfe7fde5b98da51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Pol=C3=A1=C4=8Dek?= Date: Thu, 18 Jan 2024 21:08:34 +0100 Subject: [PATCH 1/3] Fix tests I broke last time --- src/connections/stream_buffer.rs | 6 +++--- src/utils_internal.rs | 18 ++++++++---------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/connections/stream_buffer.rs b/src/connections/stream_buffer.rs index eac6b70..722e182 100644 --- a/src/connections/stream_buffer.rs +++ b/src/connections/stream_buffer.rs @@ -270,7 +270,7 @@ mod tests { // Attempt to decode packet let mut buffer = StreamBuffer::new(mock_tx); - buffer.process_incoming_bytes(encoded_packet.data().into()); + buffer.process_incoming_bytes(encoded_packet.unwrap().data().into()); assert_eq!(mock_rx.recv().await.unwrap(), packet); assert_eq!(buffer.buffer.len(), 0); @@ -295,8 +295,8 @@ mod tests { let (packet1, packet_data1) = mock_encoded_from_radio_packet(1, payload_variant1); let (packet2, packet_data2) = mock_encoded_from_radio_packet(2, payload_variant2); - let encoded_packet1 = format_data_packet(packet_data1.into()); - let encoded_packet2 = format_data_packet(packet_data2.into()); + let encoded_packet1 = format_data_packet(packet_data1.into()).unwrap(); + let encoded_packet2 = format_data_packet(packet_data2.into()).unwrap(); let (mock_tx, mut mock_rx) = unbounded_channel::(); diff --git a/src/utils_internal.rs b/src/utils_internal.rs index bf2ed66..6d55438 100644 --- a/src/utils_internal.rs +++ b/src/utils_internal.rs @@ -387,7 +387,7 @@ mod tests { let data = vec![]; let serial_data = format_data_packet(data.into()); - assert_eq!(serial_data.data(), Some(vec![0x94, 0xc3, 0x00, 0x00])); + assert_eq!(serial_data.unwrap().data(), vec![0x94, 0xc3, 0x00, 0x00]); } #[test] @@ -396,8 +396,8 @@ mod tests { let serial_data = format_data_packet(data.into()); assert_eq!( - serial_data.data(), - Some(vec![0x94, 0xc3, 0x00, 0x03, 0x00, 0xff, 0x88]) + serial_data.unwrap().data(), + vec![0x94, 0xc3, 0x00, 0x03, 0x00, 0xff, 0x88] ); } @@ -406,7 +406,10 @@ mod tests { let data = vec![0x00; 0x100]; let serial_data = format_data_packet(data.into()); - assert_eq!(serial_data.data()[..4], Some(vec![0x94, 0xc3, 0x01, 0x00])); + assert_eq!( + serial_data.unwrap().data()[..4], + vec![0x94, 0xc3, 0x01, 0x00] + ); } #[test] @@ -414,11 +417,6 @@ mod tests { let data = vec![0x00; 0x10000]; let serial_data = format_data_packet(data.into()); - assert_eq!( - serial_data, - Err(Error::InvalidaDataSize { - data_length: 0x10000 - }) - ); + assert_eq!(serial_data.is_err(), true); } } From 72e975189b647654bb338dfe95b372c45ca99fb1 Mon Sep 17 00:00:00 2001 From: Adam McQuilkin <46639306+ajmcquilkin@users.noreply.github.com> Date: Thu, 18 Jan 2024 21:02:38 -0800 Subject: [PATCH 2/3] Added testing suite --- .github/FUNDING.yml | 13 +++++++++++++ .github/workflows/testing.yml | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 .github/FUNDING.yml create mode 100644 .github/workflows/testing.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..0ccba86 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,13 @@ +# These are supported funding model platforms + +github: ajmcquilkin # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml new file mode 100644 index 0000000..f5c957f --- /dev/null +++ b/.github/workflows/testing.yml @@ -0,0 +1,34 @@ +name: "Testing Suite" +on: [push, pull_request] + +jobs: + unit-test: + permissions: + contents: write + strategy: + matrix: + platform: [macos-latest, ubuntu-20.04, windows-latest] + + runs-on: ${{ matrix.platform }} + steps: + - uses: actions/checkout@v3 + - run: git submodule update --init + + - name: Initialize Rust Cache + uses: actions/cache@v2 + with: + path: | + ~/target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + + - name: Setup pnpm + uses: pnpm/action-setup@v2 + with: + version: 8 + + - name: Install Rust stable + uses: dtolnay/rust-toolchain@stable + + - name: Run test suite + working-directory: ./ + run: cargo test From 60e57ea5d69ba9bdf72c47db6c14b0d65058fcdd Mon Sep 17 00:00:00 2001 From: Adam McQuilkin <46639306+ajmcquilkin@users.noreply.github.com> Date: Thu, 18 Jan 2024 22:11:50 -0800 Subject: [PATCH 3/3] Disabled doctests --- Cargo.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index bd7c924..fdbba32 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,9 @@ license = "GPL-3.0" version = "0.1.5" edition = "2021" +[lib] +doctest = false + [features] default = ["serde"]