Skip to content

Commit

Permalink
fix test without default features
Browse files Browse the repository at this point in the history
  • Loading branch information
yanganto committed Jul 24, 2023
1 parent 1a2ae10 commit 2d9c5fa
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 7 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ jobs:
nix_path: nixpkgs=channel:nixos-unstable

- name: Test no defualt features
run: nix develop -c cargo run --no-default-features --example instance
run: |
nix develop -c cargo run --no-default-features --example instance
nix develop -c cargo run --no-default-features --example diff
nix develop -c cargo run --no-default-features --example json
nix develop -c cargo run --no-default-features --example rename-patch-struct
nix develop -c cargo test --no-default-features
- name: Test crate
run: nix develop -c cargo test
- name: Test with default features
run: |
nix develop -c cargo run --example status
nix develop -c cargo test
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ members = [

[workspace.package]
authors = ["Antonio Yang <[email protected]>"]
version = "0.3.0"
version = "0.3.1"
edition = "2021"
categories = ["development-tools"]
keywords = ["struct", "patch", "macro", "derive", "overlay"]
Expand Down
2 changes: 1 addition & 1 deletion struct-patch/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ license.workspace = true
readme.workspace = true

[dependencies]
struct-patch-derive = { version = "=0.3.0", path = "../struct-patch-derive" }
struct-patch-derive = { version = "=0.3.1", path = "../struct-patch-derive" }

[dev-dependencies]
serde_json = "1.0"
Expand Down
7 changes: 6 additions & 1 deletion struct-patch/examples/status.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use struct_patch::{Patch, PatchStatus};
use struct_patch::Patch;
#[cfg(feature = "status")]
use struct_patch::PatchStatus;

#[derive(Default, Patch)]
#[patch_derive(Debug, Default)]
Expand All @@ -11,7 +13,10 @@ struct Item {
fn main() {
let mut patch = Item::new_empty_patch();

#[cfg(feature = "status")]
assert!(patch.is_empty()); // provided by PatchStatus
patch.field_int = Some(7);

#[cfg(feature = "status")]
assert!(!patch.is_empty());
}
5 changes: 4 additions & 1 deletion struct-patch/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ pub use traits::*;
#[cfg(test)]
mod tests {
use serde::Deserialize;
use struct_patch::{Patch, PatchStatus};
use struct_patch::Patch;
#[cfg(feature = "status")]
use struct_patch::PatchStatus;

use crate as struct_patch;

Expand Down Expand Up @@ -84,6 +86,7 @@ mod tests {
}

#[test]
#[cfg(feature = "status")]
fn test_empty() {
#[derive(Patch)]
#[patch_derive(Debug, PartialEq)]
Expand Down

0 comments on commit 2d9c5fa

Please sign in to comment.