//! Smoke test for the v0.3.6 typed bake errors. Tries to bake an
//! image that doesn't exist on the registry — should surface as
//! `Error::ImageNotFound`, not a generic Bake/Network string.

use supermachine::{Error, Image};

fn main() {
    let image_ref = "definitely-not-a-real-image-12345-abcdef:never";
    println!("=== ensure_baked({image_ref}) — should be ImageNotFound ===");
    match Image::ensure_baked("typed_errors_smoke", image_ref, |b| b) {
        Ok(_) => {
            println!("  unexpected: bake succeeded");
            std::process::exit(2);
        }
        Err(Error::ImageNotFound { image, msg, .. }) => {
            println!("  ✓ Error::ImageNotFound");
            println!("    image: {image}");
            println!("    msg:   {msg}");
        }
        Err(Error::RegistryAuth { image, msg, .. }) => {
            println!("  also acceptable: Error::RegistryAuth (Docker Hub may require auth)");
            println!("    image: {image}");
            println!("    msg:   {msg}");
        }
        Err(Error::RegistryUnreachable { msg, .. }) => {
            println!("  Error::RegistryUnreachable (offline?)");
            println!("    msg: {msg}");
        }
        Err(other) => {
            println!("  unexpected error variant: {other:?}");
            std::process::exit(1);
        }
    }
}
