Mit einem Integrations-Test können im TestServer die Endpunkte der realen Applikation getestet werden.

Ein HTTP-POST-Request zum Endpunkt /tlsrpt könnte folgend aussehen.

extern crate actix_web;
extern crate tlsrpt;

mod report_test;

use actix_web::test::TestServer;
use actix_web::http::StatusCode;
use tlsrpt::tlsrpt_mime;
use report_test::get_json_sample;
use tlsrpt::app::create_app;

#[test]
fn tlsrpt_post_valid_json_success_test() {
  let mut srv = TestServer::with_factory(create_app);

  let req = srv
    .post()
    .uri(srv.url("/tlsrpt"))
    .content_type(tlsrpt_mime::TLSRPT_JSON_STR)
    .body(get_json_sample().to_string())
    .unwrap();
  let res = srv.execute(req.send()).unwrap();

  assert_eq!(StatusCode::CREATED, res.status());
}