Skip to content

Commit

Permalink
Merge pull request #31 from h-be/full-test-coverage
Browse files Browse the repository at this point in the history
Full code test coverage
  • Loading branch information
Connoropolous authored Sep 21, 2021
2 parents c7dcd32 + 084eef8 commit a4fb845
Show file tree
Hide file tree
Showing 37 changed files with 662 additions and 237 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ jobs:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
toolchain: 1.54
target: wasm32-unknown-unknown
- run: ./scripts/dna-test.sh
- run: ./scripts/dna-test.sh
29 changes: 23 additions & 6 deletions dna/tests/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion dna/tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ edition = "2018"
[lib]

[dependencies]
hdk_crud = "0.0.103"
hdk_crud = "0.2.0"
hdk = "0.0.103"
projects = { path = "../zomes/projects" }
profiles = { path = "../zomes/profiles" }
paste = "*"
# use whatever serde hdk uses
serde = "*"
Expand All @@ -26,3 +27,6 @@ strum_macros = "0.18.0"
[features]
default = ["mock"]
mock = ["hdk/mock", "hdk/test_utils"]

[patch.crates-io]
bit-set = { git = "https://github.com/timotree3/bit-set.git", branch = "fix-bit-vec-dep" }
189 changes: 189 additions & 0 deletions dna/tests/src/fixtures.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
// in this file, you will see instances of setting up a type alias, such as `type OptionVecString = Option<Vec<String>>;`
// this is done to enable passing those to constructor functions for fixturators, like
// ```
// fixturator!(
// Goal;
// constructor fn new(..., OptionVecString, ...);
// );
// ```
#[cfg(test)]
pub(crate) mod fixtures {
use ::fixt::prelude::*;
use hdk::prelude::*;
use hdk_crud::{WrappedAgentPubKey, WrappedHeaderHash};
use profiles::profile::{Profile, Status as ProfileStatus};
use projects::project::goal::crud::{Goal, Hierarchy, Status};
use projects::project::{
edge::crud::Edge,
entry_point::crud::EntryPoint,
goal::crud::TimeFrame,
goal_comment::crud::GoalComment,
goal_member::crud::GoalMember,
goal_vote::crud::GoalVote,
member::entry::Member,
project_meta::crud::{PriorityMode, ProjectMeta},
};

fixturator!(
WrappedHeaderHash;
constructor fn new(HeaderHash);
);

fixturator!(
WrappedAgentPubKey;
constructor fn new(AgentPubKey);
);

fixturator!(
Edge;
constructor fn new(WrappedHeaderHash, WrappedHeaderHash, f64, bool);
);

fixturator!(
EntryPoint;
constructor fn new(String, WrappedAgentPubKey, f64, WrappedHeaderHash, bool);
);

fixturator!(
GoalMember;
constructor fn new(WrappedHeaderHash, WrappedAgentPubKey, WrappedAgentPubKey, f64, bool);
);

fixturator!(
GoalComment;
constructor fn new(WrappedHeaderHash, String, WrappedAgentPubKey, f64, bool);
);

fixturator!(
GoalVote;
constructor fn new(WrappedHeaderHash, f64, f64, f64, f64, WrappedAgentPubKey, f64, bool);
);

fixturator!(
Member;
constructor fn new(WrappedAgentPubKey);
);

fixturator!(
ProjectMeta;
constructor fn new(WrappedAgentPubKey, f64, String, OptionString, String, bool, PriorityMode, VecWrappedHeaderHash);
);

type VecWrappedHeaderHash = Vec<WrappedHeaderHash>;
type OptionWrappedAgentPubKey = Option<WrappedAgentPubKey>;
type OptionString = Option<String>;
type Optionf64 = Option<f64>;
type OptionVecString = Option<Vec<String>>;
type OptionTimeFrame = Option<TimeFrame>;

fixturator!(
PriorityMode;
unit variants [ Universal Vote ] empty Universal;
);

fixturator!(
TimeFrame;
constructor fn new(f64, f64);
);

fixturator!(
Status;
unit variants [ Uncertain Incomplete InProcess Complete InReview ] empty Uncertain;
);

fixturator!(
Hierarchy;
unit variants [Root Trunk Branch Leaf NoHierarchy ] empty NoHierarchy;
);

fixturator!(
VecWrappedHeaderHash;
curve Empty {
Vec::new()
};
curve Unpredictable {
vec![WrappedHeaderHashFixturator::new(Unpredictable).next().unwrap()]
};
curve Predictable {
vec![WrappedHeaderHashFixturator::new(Predictable).next().unwrap()]
};
);

fixturator!(
OptionWrappedAgentPubKey;
curve Empty {
None
};
curve Unpredictable {
Some(WrappedAgentPubKeyFixturator::new(Unpredictable).next().unwrap())
};
curve Predictable {
Some(WrappedAgentPubKeyFixturator::new(Predictable).next().unwrap())
};
);

fixturator!(
OptionString;
curve Empty {
None
};
curve Unpredictable {
Some(fixt!(String))
};
curve Predictable {
Some(fixt!(String, Predictable))
};
);

fixturator!(
Optionf64;
curve Empty {
None
};
curve Unpredictable {
Some(fixt!(f64))
};
curve Predictable {
Some(fixt!(f64, Predictable))
};
);

fixturator!(
OptionVecString;
curve Empty {
None
};
curve Unpredictable {
Some(Vec::new())
};
curve Predictable {
Some(Vec::new())
};
);

fixturator!(
OptionTimeFrame;
curve Empty {
None
};
curve Unpredictable {
Some(TimeFrameFixturator::new(Unpredictable).next().unwrap())
};
curve Predictable {
Some(TimeFrameFixturator::new(Predictable).next().unwrap())
};
);

fixturator!(
Goal;
constructor fn new(String, WrappedAgentPubKey, OptionWrappedAgentPubKey, f64, Optionf64, Hierarchy, Status, OptionVecString, String, OptionTimeFrame, bool);
);
fixturator!(
ProfileStatus;
unit variants [ Online Away Offline ] empty Offline;
);
fixturator!(
Profile;
constructor fn new(String, String, String, ProfileStatus, String, WrappedAgentPubKey, bool);
);
}
5 changes: 4 additions & 1 deletion dna/tests/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
mod project;
mod project;
mod profiles;
mod test_lib;
mod fixtures;
1 change: 1 addition & 0 deletions dna/tests/src/profiles/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod profile;
Loading

0 comments on commit a4fb845

Please sign in to comment.