Unify some testing interfaces

This tidies up our testing tools a little bit.  We had several
functions which through various changes ended up doing the same and
some more which did very similar stuff, so I merged them to have
things simpler.  Also moved towards methods on the TestContext struct
while cleaning this up anyway, seems like this structure is going to
stay around for a bit anyway.

The intersting change is in `test_utils.rs`, everything else is just
updating callers.  A few tests used example.org which I moved to
example.com to be able to re-use more configuration of the test
context.
This commit is contained in:
Floris Bruynooghe
2020-06-19 20:23:05 +02:00
parent 73412db267
commit 9d7b756ddb
24 changed files with 253 additions and 250 deletions

View File

@@ -383,11 +383,11 @@ fn normalize_address(addr: &str) -> Result<String, Error> {
mod tests {
use super::*;
use crate::test_utils::dummy_context;
use crate::test_utils::TestContext;
#[async_std::test]
async fn test_decode_http() {
let ctx = dummy_context().await;
let ctx = TestContext::new().await;
let res = check_qr(&ctx.ctx, "http://www.hello.com").await;
@@ -399,7 +399,7 @@ mod tests {
#[async_std::test]
async fn test_decode_https() {
let ctx = dummy_context().await;
let ctx = TestContext::new().await;
let res = check_qr(&ctx.ctx, "https://www.hello.com").await;
@@ -411,7 +411,7 @@ mod tests {
#[async_std::test]
async fn test_decode_text() {
let ctx = dummy_context().await;
let ctx = TestContext::new().await;
let res = check_qr(&ctx.ctx, "I am so cool").await;
@@ -423,7 +423,7 @@ mod tests {
#[async_std::test]
async fn test_decode_vcard() {
let ctx = dummy_context().await;
let ctx = TestContext::new().await;
let res = check_qr(
&ctx.ctx,
@@ -441,7 +441,7 @@ mod tests {
#[async_std::test]
async fn test_decode_matmsg() {
let ctx = dummy_context().await;
let ctx = TestContext::new().await;
let res = check_qr(
&ctx.ctx,
@@ -459,7 +459,7 @@ mod tests {
#[async_std::test]
async fn test_decode_mailto() {
let ctx = dummy_context().await;
let ctx = TestContext::new().await;
let res = check_qr(
&ctx.ctx,
@@ -485,7 +485,7 @@ mod tests {
#[async_std::test]
async fn test_decode_smtp() {
let ctx = dummy_context().await;
let ctx = TestContext::new().await;
let res = check_qr(&ctx.ctx, "SMTP:stress@test.local:subjecthello:bodyworld").await;
@@ -499,7 +499,7 @@ mod tests {
#[async_std::test]
async fn test_decode_openpgp_group() {
let ctx = dummy_context().await;
let ctx = TestContext::new().await;
let res = check_qr(
&ctx.ctx,
@@ -528,7 +528,7 @@ mod tests {
#[async_std::test]
async fn test_decode_openpgp_secure_join() {
let ctx = dummy_context().await;
let ctx = TestContext::new().await;
let res = check_qr(
&ctx.ctx,
@@ -556,7 +556,7 @@ mod tests {
#[async_std::test]
async fn test_decode_openpgp_without_addr() {
let ctx = dummy_context().await;
let ctx = TestContext::new().await;
let res = check_qr(
&ctx.ctx,
@@ -591,7 +591,7 @@ mod tests {
#[async_std::test]
async fn test_decode_account() {
let ctx = dummy_context().await;
let ctx = TestContext::new().await;
let res = check_qr(
&ctx.ctx,
@@ -613,7 +613,7 @@ mod tests {
#[async_std::test]
async fn test_decode_account_bad_scheme() {
let ctx = dummy_context().await;
let ctx = TestContext::new().await;
let res = check_qr(
&ctx.ctx,
"DCACCOUNT:http://example.org/new_email?t=1w_7wDjgjelxeX884x96v3",