11//! Integration test for comment document validation part.
22
33use catalyst_signed_doc:: { providers:: tests:: TestCatalystSignedDocumentProvider , * } ;
4+ use catalyst_types:: id_uri:: role_index:: RoleIndex ;
45
56mod common;
67
@@ -12,21 +13,24 @@ async fn test_valid_comment_doc() {
1213 common:: create_dummy_doc ( doc_types:: COMMENT_TEMPLATE_UUID_TYPE ) . unwrap ( ) ;
1314
1415 let uuid_v7 = UuidV7 :: new ( ) ;
15- let ( doc, ..) = common:: create_dummy_signed_doc ( Some ( serde_json:: json!( {
16- "content-type" : ContentType :: Json . to_string( ) ,
17- "content-encoding" : ContentEncoding :: Brotli . to_string( ) ,
18- "type" : doc_types:: COMMENT_DOCUMENT_UUID_TYPE ,
19- "id" : uuid_v7. to_string( ) ,
20- "ver" : uuid_v7. to_string( ) ,
21- "template" : {
22- "id" : template_doc_id,
23- "ver" : template_doc_ver
24- } ,
25- "ref" : {
26- "id" : proposal_doc_id,
27- "ver" : proposal_doc_ver
28- }
29- } ) ) )
16+ let ( doc, ..) = common:: create_dummy_signed_doc (
17+ Some ( serde_json:: json!( {
18+ "content-type" : ContentType :: Json . to_string( ) ,
19+ "content-encoding" : ContentEncoding :: Brotli . to_string( ) ,
20+ "type" : doc_types:: COMMENT_DOCUMENT_UUID_TYPE ,
21+ "id" : uuid_v7. to_string( ) ,
22+ "ver" : uuid_v7. to_string( ) ,
23+ "template" : {
24+ "id" : template_doc_id,
25+ "ver" : template_doc_ver
26+ } ,
27+ "ref" : {
28+ "id" : proposal_doc_id,
29+ "ver" : proposal_doc_ver
30+ }
31+ } ) ) ,
32+ RoleIndex :: ROLE_0 ,
33+ )
3034 . unwrap ( ) ;
3135
3236 let mut provider = TestCatalystSignedDocumentProvider :: default ( ) ;
@@ -66,25 +70,28 @@ async fn test_valid_comment_doc_with_reply() {
6670 . build ( ) ;
6771
6872 let uuid_v7 = UuidV7 :: new ( ) ;
69- let ( doc, ..) = common:: create_dummy_signed_doc ( Some ( serde_json:: json!( {
70- "content-type" : ContentType :: Json . to_string( ) ,
71- "content-encoding" : ContentEncoding :: Brotli . to_string( ) ,
72- "type" : doc_types:: COMMENT_DOCUMENT_UUID_TYPE ,
73- "id" : uuid_v7. to_string( ) ,
74- "ver" : uuid_v7. to_string( ) ,
75- "template" : {
76- "id" : template_doc_id,
77- "ver" : template_doc_ver
78- } ,
79- "ref" : {
80- "id" : proposal_doc_id,
81- "ver" : proposal_doc_ver
82- } ,
83- "reply" : {
84- "id" : comment_doc_id,
85- "ver" : comment_doc_ver
86- }
87- } ) ) )
73+ let ( doc, ..) = common:: create_dummy_signed_doc (
74+ Some ( serde_json:: json!( {
75+ "content-type" : ContentType :: Json . to_string( ) ,
76+ "content-encoding" : ContentEncoding :: Brotli . to_string( ) ,
77+ "type" : doc_types:: COMMENT_DOCUMENT_UUID_TYPE ,
78+ "id" : uuid_v7. to_string( ) ,
79+ "ver" : uuid_v7. to_string( ) ,
80+ "template" : {
81+ "id" : template_doc_id,
82+ "ver" : template_doc_ver
83+ } ,
84+ "ref" : {
85+ "id" : proposal_doc_id,
86+ "ver" : proposal_doc_ver
87+ } ,
88+ "reply" : {
89+ "id" : comment_doc_id,
90+ "ver" : comment_doc_ver
91+ }
92+ } ) ) ,
93+ RoleIndex :: ROLE_0 ,
94+ )
8895 . unwrap ( ) ;
8996
9097 let mut provider = TestCatalystSignedDocumentProvider :: default ( ) ;
@@ -105,19 +112,22 @@ async fn test_invalid_comment_doc() {
105112 common:: create_dummy_doc ( doc_types:: COMMENT_TEMPLATE_UUID_TYPE ) . unwrap ( ) ;
106113
107114 let uuid_v7 = UuidV7 :: new ( ) ;
108- let ( doc, ..) = common:: create_dummy_signed_doc ( Some ( serde_json:: json!( {
109- "content-type" : ContentType :: Json . to_string( ) ,
110- "content-encoding" : ContentEncoding :: Brotli . to_string( ) ,
111- "type" : doc_types:: COMMENT_DOCUMENT_UUID_TYPE ,
112- "id" : uuid_v7. to_string( ) ,
113- "ver" : uuid_v7. to_string( ) ,
114- "template" : {
115- "id" : template_doc_id,
116- "ver" : template_doc_ver
117- } ,
118- // without ref
119- "ref" : serde_json:: Value :: Null
120- } ) ) )
115+ let ( doc, ..) = common:: create_dummy_signed_doc (
116+ Some ( serde_json:: json!( {
117+ "content-type" : ContentType :: Json . to_string( ) ,
118+ "content-encoding" : ContentEncoding :: Brotli . to_string( ) ,
119+ "type" : doc_types:: COMMENT_DOCUMENT_UUID_TYPE ,
120+ "id" : uuid_v7. to_string( ) ,
121+ "ver" : uuid_v7. to_string( ) ,
122+ "template" : {
123+ "id" : template_doc_id,
124+ "ver" : template_doc_ver
125+ } ,
126+ // without ref
127+ "ref" : serde_json:: Value :: Null
128+ } ) ) ,
129+ RoleIndex :: ROLE_0 ,
130+ )
121131 . unwrap ( ) ;
122132
123133 let mut provider = TestCatalystSignedDocumentProvider :: default ( ) ;
0 commit comments