tesults 1.0.0

Upload test results to Tesults
Documentation
use std::collections::HashMap;
use std::time::{SystemTime, UNIX_EPOCH};
use tesults::{Case, Data, Step};

fn now_ms() -> i64 {
    SystemTime::now()
        .duration_since(UNIX_EPOCH)
        .unwrap_or_default()
        .as_millis() as i64
}

fn main() {
    // Basic pass
    let tc1 = Case {
        name:   "Test 1".into(),
        desc:   "Test 1 description".into(),
        suite:  "Suite A".into(),
        result: "pass".into(),
        ..Default::default()
    };

    // Pass with timing, params, and a custom field
    let tc2 = Case {
        name:   "Test 2".into(),
        desc:   "Test 2 description".into(),
        suite:  "Suite B".into(),
        result: "pass".into(),
        start:  now_ms() - 60_000,
        end:    now_ms(),
        params: HashMap::from([
            ("param1".into(), "value1".into()),
            ("param2".into(), "value2".into()),
        ]),
        custom: HashMap::from([
            ("CustomField".into(), "Custom field value".into()),
        ]),
        ..Default::default()
    };

    // Fail with reason, files, and steps
    let tc3 = Case {
        name:   "Test 3".into(),
        desc:   "Test 3 description".into(),
        suite:  "Suite A".into(),
        result: "fail".into(),
        reason: "Assert failed at line 203 of example.rs".into(),
        files:  vec![
            "/path/to/log.txt".into(),
            "/path/to/screenshot.png".into(),
        ],
        steps: vec![
            Step { name: "Step 1".into(), result: "pass".into(), desc: "Step 1 description".into(), reason: "".into() },
            Step { name: "Step 2".into(), result: "fail".into(), desc: "Step 2 description".into(), reason: "Unexpected value".into() },
        ],
        ..Default::default()
    };

    let data = Data {
        target: "token".into(), // replace with your target token
        cases:  vec![tc1, tc2, tc3],
        ..Default::default()
    };

    println!("Tesults results upload...");
    let response = tesults::upload(data);
    println!("Success: {}", response.success);
    println!("Message: {}", response.message);
    println!("Warnings: {}", response.warnings.len());
    println!("Errors: {}", response.errors.len());

    std::process::exit(if response.success { 0 } else { 1 });
}