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 diff --git a/Cargo.toml b/Cargo.toml index 22d12b1..7de47e8 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"] 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 14fa531..519818d 100644 --- a/src/utils_internal.rs +++ b/src/utils_internal.rs @@ -439,7 +439,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] @@ -448,8 +448,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] ); } @@ -458,7 +458,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] @@ -466,11 +469,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); } }