mod v1 {
use std::fs::read;
use crate::schema::v1::{Cohort, Family, Phenopacket};
use prost::Message;
const V1_PHENOPACKET: &str = "data/v1/phenopacket.pb";
const V1_FAMILY: &str = "data/v1/family.pb";
const V1_COHORT: &str = "data/v1/cohort.pb";
#[test]
fn decode_phenopacket() {
let buf = read(V1_PHENOPACKET).expect("The test file should be present in the repo!");
let actual = Phenopacket::decode(&buf[..]).unwrap();
assert_eq!(&actual.id, "comprehensive-phenopacket-id");
}
#[test]
fn decode_family() {
let buf = read(V1_FAMILY).expect("The test file should be present in the repo!");
let family = Family::decode(&buf[..]).unwrap();
assert_eq!(&family.id, "comprehensive-family-id");
}
#[test]
fn decode_cohort() {
let buf = read(V1_COHORT).expect("The test file should be present in the repo!");
let family = Cohort::decode(&buf[..]).unwrap();
assert_eq!(&family.id, "comprehensive-cohort-id");
}
}
mod v2 {
use std::fs::read;
use prost::Message;
use crate::{
schema::v2::{Cohort, Family, Phenopacket},
tests::examples::v2,
};
const V2_PHENOPACKET: &str = "data/v2/phenopacket.pb";
const V2_FAMILY: &str = "data/v2/family.pb";
const V2_COHORT: &str = "data/v2/cohort.pb";
#[test]
fn decode_phenopacket() {
let buf = read(V2_PHENOPACKET).expect("The test file should be present in the repo!");
let actual = Phenopacket::decode(&*buf).unwrap();
let expected = v2::phenopacket();
assert_eq!(actual, expected);
}
#[test]
fn decode_family() {
let buf = read(V2_FAMILY).unwrap();
let actual = Family::decode(&*buf).unwrap();
let expected = v2::family();
assert_eq!(actual, expected);
}
#[test]
fn decode_cohort() {
let buf = read(V2_COHORT).expect("The test file should be present in the repo!");
let actual = Cohort::decode(&*buf).unwrap();
let expected = v2::cohort();
assert_eq!(actual, expected);
}
}