armature-testing

Crates.ioarmature-testing
lib.rsarmature-testing
version0.1.2
created_at2025-12-27 02:04:43.827305+00
updated_at2025-12-30 22:34:32.914395+00
descriptionTesting utilities for Armature applications
homepagehttps://pegasusheavy.github.io/armature
repositoryhttps://github.com/pegasusheavy/armature
max_upload_size
id2006574
size130,054
Joseph R. Quinn (quinnjr)

documentation

README

armature-testing

Testing utilities for the Armature framework.

Features

  • Test Client - HTTP client for testing handlers
  • Mock Services - Mock external dependencies
  • Fixtures - Database and state fixtures
  • Assertions - HTTP response assertions
  • Integration Tests - Full application testing

Installation

[dev-dependencies]
armature-testing = "0.1"

Quick Start

use armature_testing::{TestClient, assert_status};

#[tokio::test]
async fn test_hello_endpoint() {
    let app = create_test_app();
    let client = TestClient::new(app);

    let response = client.get("/hello").send().await;

    assert_status!(response, 200);
    assert_eq!(response.text().await, "Hello, World!");
}

Test Client

let client = TestClient::new(app);

// GET request
let resp = client.get("/users").send().await;

// POST with JSON
let resp = client.post("/users")
    .json(&user)
    .send()
    .await;

// With headers
let resp = client.get("/api/data")
    .header("Authorization", "Bearer token")
    .send()
    .await;

Assertions

assert_status!(response, 200);
assert_json!(response, {"id": 1, "name": "Test"});
assert_header!(response, "Content-Type", "application/json");

License

MIT OR Apache-2.0

Commit count: 0

cargo fmt