Skip to content

Commit

Permalink
feat: add test for http request
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Oct 5, 2022
1 parent f8c8ca3 commit dc48bc1
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions crates/fkl_parser/src/parser/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::collections::HashMap;

use pest::iterators::{Pair, Pairs};

use crate::parser::ast::{AggregateDecl, AttributeDefinition, AuthorizationDecl, BoundedContextDecl, ComponentDecl, ContextMapDecl, ContextRelation, EndpointDecl, EntityDecl, FklDeclaration, HttpResponseDecl, Identifier, ImplementationDecl, Loc, RelationDirection, StructDecl, UsedDomainObject, ValueObjectDecl, VariableDefinition};
use crate::parser::ast::{AggregateDecl, AttributeDefinition, AuthorizationDecl, BoundedContextDecl, ComponentDecl, ContextMapDecl, ContextRelation, EndpointDecl, EntityDecl, FklDeclaration, HttpRequestDecl, HttpResponseDecl, Identifier, ImplementationDecl, Loc, RelationDirection, StructDecl, UsedDomainObject, ValueObjectDecl, VariableDefinition};
use crate::parser::parse_result::{ParseError, ParseResult};
use crate::pest::Parser;

Expand Down Expand Up @@ -429,6 +429,18 @@ fn consume_endpoint(pair: Pair<Rule>) -> EndpointDecl {
}
}
}
Rule::request_body => {
for inner in p.into_inner() {
match inner.as_rule() {
Rule::identifier => {
endpoint.request = Some(HttpRequestDecl {
name: inner.as_str().to_string(),
});
}
_ => println!("unreachable http_request_decl rule: {:?}", inner.as_rule())
}
}
}
Rule::authorization_decl => {
endpoint.authorization = Some(consume_authorization(p));
}
Expand Down Expand Up @@ -1050,7 +1062,9 @@ imple CinemaCreatedEvent {
username: Some("admin".to_string()),
password: Some("admin".to_string()),
}),
request: None,
request: Some(HttpRequestDecl {
name: "CinemaUpdatedRequest".to_string()
}),
response: Some(HttpResponseDecl {
name: "Cinema".to_string()
}),
Expand Down

0 comments on commit dc48bc1

Please sign in to comment.