Skip to content

Improving the examples - adding tests #3263

Open
@szabgab

Description

@szabgab

Looking at the examples in the examples folder I see that many don't come with tests.
Having tests with the examples will both help make sure that they stay correct as axum changes and it will help the would be developers to learn how to test.

As I see many of the examples have

async fn main() {
   ...
   let app = Router::new()
   ...
}

This, as far as I understand, makes it impossible to use the router in the tests. So I think it would be a good idea to refactor these examples to defined a function

fn app() -> Router {
}

and then write

async fn main() {
   ...
   let app: Router = app();
   ...
}

I'd be happy to do this work for some of the examples, but I'd like to know if you even consider this a good idea.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions