Skip to content

Commit

Permalink
test(codegen): test from file domain input with acronyms
Browse files Browse the repository at this point in the history
Signed-off-by: Joseph Livesey <joseph.livesey@btp.works>
  • Loading branch information
suchapalaver committed Dec 2, 2022
1 parent 046b6fe commit 0180401
Showing 1 changed file with 132 additions and 0 deletions.
132 changes: 132 additions & 0 deletions crates/chronicle/src/codegen/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1180,4 +1180,136 @@ pub mod test {

Ok(())
}

fn create_test_yaml_file_with_acronyms(
) -> Result<assert_fs::NamedTempFile, Box<dyn std::error::Error>> {
let file = assert_fs::NamedTempFile::new("test.yml")?;
file.write_str(
r#"
name: "evidence"
attributes:
Content:
type: String
CMSId:
type: String
Title:
type: String
SearchParameter:
type: String
Reference:
type: String
Version:
type: Int
entities:
Question:
attributes:
- CMSId
- Content
EvidenceReference:
attributes:
- SearchParameter
- Reference
Guidance:
attributes:
- Title
- Version
PublishedGuidance:
attributes: []
activities:
QuestionAsked:
attributes:
- Content
Researched:
attributes: []
Published:
attributes:
- Version
Revised:
attributes:
- CMSId
- Version
agents:
Person:
attributes:
- CMSId
Organization:
attributes:
- Title
roles:
- STAKEHOLDER
- AUTHOR
- RESEARCHER
- EDITOR
"#,
)?;
Ok(file)
}

#[test]
fn test_from_domain_for_file_input_with_inflections() -> Result<(), Box<dyn std::error::Error>>
{
let file = create_test_yaml_file_with_acronyms()?;
let s: String = std::fs::read_to_string(file.path())?;
let domain = ChronicleDomainDef::from_str(&s)?;
let input = DomainFileInput::from(&domain);

insta::assert_yaml_snapshot!(input, @r###"
---
name: evidence
attributes:
CMSId:
type: String
Content:
type: String
Reference:
type: String
SearchParameter:
type: String
Title:
type: String
Version:
type: Int
agents:
OrganizationAgent:
attributes:
- Title
PersonAgent:
attributes:
- CMSId
entities:
EvidenceReferenceEntity:
attributes:
- SearchParameter
- Reference
GuidanceEntity:
attributes:
- Title
- Version
PublishedGuidanceEntity:
attributes: []
QuestionEntity:
attributes:
- CMSId
- Content
activities:
PublishedActivity:
attributes:
- Version
QuestionAskedActivity:
attributes:
- Content
ResearchedActivity:
attributes: []
RevisedActivity:
attributes:
- CMSId
- Version
roles:
- Stakeholder
- Author
- Researcher
- Editor
"###);
Ok(())
}
}

0 comments on commit 0180401

Please sign in to comment.