1
0
mirror of https://github.com/actix/examples synced 2025-02-08 20:06:07 +01:00

Bump yarte version to 0.2.1 (#153)

This commit is contained in:
Juan Aguilar 2019-07-01 06:02:14 +02:00 committed by Nikolay Kim
parent ed24f61cca
commit 7c747c5006
3 changed files with 27 additions and 27 deletions

View File

@ -1,7 +1,7 @@
[package] [package]
name = "template_yarte" name = "template_yarte"
version = "0.0.1" version = "0.0.1"
authors = ["Rust-iendo Barcelona <riendocontributions@gmail.com>"] authors = ["Rust-iendo <riendocontributions@gmail.com>"]
publish = false publish = false
edition = "2018" edition = "2018"
@ -12,12 +12,10 @@ env_logger = "0.6"
yarte = { version = "0.2", features=["with-actix-web"] } yarte = { version = "0.2", features=["with-actix-web"] }
actix-web = "1.0.0" actix-web = "1.0"
[build-dependencies] [build-dependencies]
yarte = { version = "0.2", features=["with-actix-web"] } yarte = { version = "0.2", features=["with-actix-web"] }
[dev-dependencies] [dev-dependencies]
bytes = "0.4" bytes = "0.4"
actix-http-test = "0.2.0"
actix-http = "0.2.3"

View File

@ -1,6 +1,6 @@
# yarte # yarte
Example of composition with partials and `with-actix-web` feature Minimal example of using template [yarte](https://gitlab.com/r-iendo/yarte) that displays a form.
```bash ```bash
cargo test cargo test

View File

@ -30,25 +30,24 @@ fn main() -> std::io::Result<()> {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*; use super::*;
use actix_http::HttpService; use actix_web::{http, test as atest};
use actix_http_test::TestServer;
use actix_web::{http, App};
use bytes::Bytes; use bytes::Bytes;
#[test] #[test]
fn test() { fn test() {
let mut srv = TestServer::new(|| HttpService::new(App::new().service(index))); let mut app = atest::init_service(App::new().service(index));
let req = srv.get("/"); let req = atest::TestRequest::with_uri("/").to_request();
let mut response = srv.block_on(req.send()).unwrap(); let resp = atest::call_service(&mut app, req);
assert!(response.status().is_success());
assert!(resp.status().is_success());
assert_eq!( assert_eq!(
response.headers().get(http::header::CONTENT_TYPE).unwrap(), resp.headers().get(http::header::CONTENT_TYPE).unwrap(),
"text/html" "text/html"
); );
let bytes = srv.block_on(response.body()).unwrap(); let bytes = atest::read_body(resp);
assert_eq!( assert_eq!(
bytes, bytes,
Bytes::from_static( Bytes::from_static(
@ -67,16 +66,17 @@ mod test {
) )
); );
let req = srv.get("/?name=foo&lastname=bar"); let req = atest::TestRequest::with_uri("/?name=foo&lastname=bar").to_request();
let mut response = srv.block_on(req.send()).unwrap(); let resp = atest::call_service(&mut app, req);
assert!(response.status().is_success());
assert!(resp.status().is_success());
assert_eq!( assert_eq!(
response.headers().get(http::header::CONTENT_TYPE).unwrap(), resp.headers().get(http::header::CONTENT_TYPE).unwrap(),
"text/html" "text/html"
); );
let bytes = srv.block_on(response.body()).unwrap(); let bytes = atest::read_body(resp);
assert_eq!( assert_eq!(
bytes, bytes,
Bytes::from_static( Bytes::from_static(
@ -90,20 +90,22 @@ mod test {
) )
); );
let req = srv.get("/?name=foo"); let req = atest::TestRequest::with_uri("/?name=foo").to_request();
let mut response = srv.block_on(req.send()).unwrap(); let resp = atest::call_service(&mut app, req);
assert!(response.status().is_server_error());
let req = srv.get("/?lastname=bar"); assert!(resp.status().is_server_error());
let mut response = srv.block_on(req.send()).unwrap();
assert!(response.status().is_success()); let req = atest::TestRequest::with_uri("/?lastname=bar").to_request();
let resp = atest::call_service(&mut app, req);
assert!(resp.status().is_success());
assert_eq!( assert_eq!(
response.headers().get(http::header::CONTENT_TYPE).unwrap(), resp.headers().get(http::header::CONTENT_TYPE).unwrap(),
"text/html" "text/html"
); );
let bytes = srv.block_on(response.body()).unwrap(); let bytes = atest::read_body(resp);
assert_eq!( assert_eq!(
bytes, bytes,
Bytes::from_static( Bytes::from_static(