made_api/
authoring_views.rs1use serde::{Deserialize, Serialize};
2
3use crate::DefinitionDefectView;
4
5#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
10pub struct DefinitionAnalysisView {
11 pub definition_name: String,
13 pub definition_version: String,
14 pub publishable: bool,
16 pub definition_digest: Option<String>,
22 pub defects: Vec<DefinitionDefectView>,
23}
24
25#[cfg(test)]
26mod tests {
27 use super::*;
28 use crate::PublishedDefinitionView;
29
30 #[test]
31 fn an_analysis_survives_the_wire() {
32 let analysis = DefinitionAnalysisView {
33 definition_name: "scope_discovery".to_owned(),
34 definition_version: "1.0".to_owned(),
35 publishable: false,
36 definition_digest: None,
37 defects: vec![DefinitionDefectView {
38 severity: "error".to_owned(),
39 locus: "state `ORPHAN`".to_owned(),
40 defect: "state is unreachable".to_owned(),
41 blocking: true,
42 }],
43 };
44 let bytes = serde_json::to_vec(&analysis).expect("serializes");
45 assert_eq!(
46 serde_json::from_slice::<DefinitionAnalysisView>(&bytes).expect("deserializes"),
47 analysis
48 );
49 }
50
51 #[test]
52 fn a_publication_names_what_an_instance_will_bind_to() {
53 let published = PublishedDefinitionView {
54 name: "scope_discovery".to_owned(),
55 version: "1.0".to_owned(),
56 digest: "abc123".to_owned(),
57 already_published: false,
58 };
59 assert!(
60 !published.digest.is_empty(),
61 "a publication without a digest cannot be bound to, only believed"
62 );
63 }
64}